/** * tpl {include_clipcache} function plugin * * Includes a template using private caching parameters. Must be registered as non-caching. * * @file function.include_clipcache.php * @version 0.1.7 2006-May-11 * @since 2005-APR-08 * * @author boots {jayboots ~ yahoo com} * @copyright brainpower, boots, 2004-2006 * @license LGPL 2.1 * @link http://www.phpinsider.com/tpl-forum/viewtopic.php?p=19733#19733 * * @param array $params * @param tpl $tpl * * This function observes the following tag attributes (in $params): * * #param file required template file * #param cache_id required specify cache build group * #param cache_lifetime required time to live for template part/group * #param ldelim optional specify the left delimiter to use for included content * #param rdelim optional specify the right delimiter to use for included content */ function tpl_function_include_clipcache($params, &$tpl) { // validation foreach (array('cache_id', 'file', 'cache_lifetime') as $required) { if (!array_key_exists($required, $params)) { $tpl->trigger_error("include_clipcache: '{$required}' param missing. Aborted.", E_USER_WARNING); return; } } // handle optional delimiters foreach (array('rdelim' => $tpl->right_delimiter, 'ldelim' => $tpl->left_delimiter) as $optional => $default) { ${"_{$optional}"} = $default; ${$optional} = array_key_exists($optional, $params) ? $params[$optional] : $default; } $tpl->compile_check = false; // save tpl environment as proposed by calling template $_caching = $tpl->cache; if (caching == 1) { $tpl->cache = 2; } $_cache_lifetime = $tpl->cache_lifetime; $tpl->cache_lifetime = $params['cache_lifetime']; $tpl->left_delimiter = $ldelim; $tpl->right_delimiter = $rdelim; // run the requested clipcache template $content = $tpl->fetch($params['file'], $params['cache_id']); // restore tpl environment as proposed by calling template $tpl->cache = $_caching; $tpl->cache_lifetime = $_cache_lifetime; $tpl->left_delimiter = $_ldelim; $tpl->right_delimiter = $_rdelim; return $content; }
/** * Возвращает шаблон, * заполненный данными переданными в параметре * * @param tpl $tpl * @param array $item * @return tpl */ function getItem($tpl, $item) { $tplItem = $tpl->fetchBlock('BreadCrumbs'); $tplItem->assign($item); $tpl->assign('BreadCrumbs', $tplItem); $tplItem->reset(); return $tpl; }
function check_session() { if (!isset($_SESSION['user_name'])) { $tpl = new tpl(); $data = array('html_header' => $tpl->html_header, 'show_login' => $tpl->show_login); echo $tpl->replace_vars($tpl->html_show_login, $data); die; } }
/** * Zeigt das Formular an, in dem User ihre Einträge machen können * * @param $text Vorbelegung für den text * @param $mail Vorbelegung für die Emailadresse * @param $page Vorbelegung für die Homepage */ function showForm($text = "", $mail = "", $page = "", $fehler = "") { global $allgAr; $tpl = new tpl('gbook.htm'); $ar = array('uname' => $_SESSION['authname'], 'SMILIES' => getsmilies(), 'ANTISPAM' => get_antispam('gbook', 1), 'TXTL' => $allgAr['Gtxtl'], 'TEXT' => $text, 'PAGE' => $page, 'MAIL' => $mail, 'FEHLER' => $fehler); $tpl->set_ar_out($ar, "formular_eintrag"); if (!isset($_SESSION['klicktime_gbook'])) { $_SESSION['klicktime_gbook'] = 0; } }
function update($event_name, $data) { global $app, $conf; // load the server configuration options $app->uses("getconf"); $mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail'); if (substr($mail_config["homedir_path"], -1) == '/') { $mail_config["homedir_path"] = substr($mail_config["homedir_path"], 0, -1); } if (isset($data["new"]["email"])) { $email_parts = explode("@", $data["new"]["email"]); } else { $email_parts = explode("@", $data["old"]["email"]); } // Write the custom mailfilter script, if mailfilter recipe has changed if ($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"] or $data["old"]["move_junk"] != $data["new"]["move_junk"] or $data["old"]["autoresponder_text"] != $data["new"]["autoresponder_text"] or $data["old"]["autoresponder"] != $data["new"]["autoresponder"] or isset($data["new"]["email"]) and $data["old"]["email"] != $data["new"]["email"] or $data["old"]["autoresponder_start_date"] != $data["new"]["autoresponder_start_date"] or $data["old"]["autoresponder_end_date"] != $data["new"]["autoresponder_end_date"] or $data["old"]["cc"] != $data["new"]["cc"]) { $app->log("Mailfilter config has been changed", LOGLEVEL_DEBUG); $sieve_file = $data["new"]["maildir"] . '/.sieve'; if (is_file($sieve_file)) { unlink($sieve_file) or $app->log("Unable to delete file: {$sieve_file}", LOGLEVEL_WARN); } $app->load('tpl'); $tpl = new tpl(); $tpl->newTemplate("sieve_filter.master"); // cc Field $tpl->setVar('cc', $data["new"]["cc"]); // Custom filters $tpl->setVar('custom_mailfilter', $data["new"]["custom_mailfilter"]); // Move junk $tpl->setVar('move_junk', $data["new"]["move_junk"]); // Set autoresponder start date $tpl->setVar('start_date', $data["new"]["autoresponder_start_date"]); // Set autoresponder end date $tpl->setVar('end_date', $data["new"]["autoresponder_end_date"]); // Autoresponder $tpl->setVar('autoresponder', $data["new"]["autoresponder"]); $data["new"]["autoresponder_text"] = str_replace("\"", "'", $data["new"]["autoresponder_text"]); $tpl->setVar('autoresponder_text', $data["new"]["autoresponder_text"]); //* Set alias addresses for autoresponder $sql = "SELECT * FROM mail_forwarding WHERE type = 'alias' AND destination = '" . $app->db->quote($data["new"]["email"]) . "'"; $records = $app->db->queryAllRecords($sql); $addresses = ''; if (is_array($records) && count($records) > 0) { $addresses .= ':addresses ["' . $data["new"]["email"] . '",'; foreach ($records as $rec) { $addresses .= '"' . $rec['source'] . '",'; } $addresses = substr($addresses, 0, -1); $addresses .= ']'; } $tpl->setVar('addresses', $addresses); file_put_contents($sieve_file, $tpl->grab()); unset($tpl); } }
function show_sitemap($q, $lv, $table, $menu, $where, $was) { $limit = 200; $page = $menu->getA(2) == 'p' ? $menu->getE(2) : 1; $MPL = db_make_sites($page, $where, $limit, '?sitemap-' . $menu->get(1), $table); $anfang = ($page - 1) * $limit; $q = db_query($q . " LIMIT " . $anfang . "," . $limit); $tpl = new tpl('sitemap'); $l = ''; while ($r = db_fetch_row($q)) { $l .= $tpl->list_get('links', array(str_replace('{id}', $r[0], $lv), $r[1])); } $tpl->set_ar_out(array('MPL' => $MPL, 'site' => $was, 'links' => $l), 1); }
public function __construct($title, $hmenu, $was = 1, $file = null) { global $allgAr, $menu; header('Content-Type: text/html;charset=UTF-8'); if (AJAXCALL) { $this->ajax = true; $this->json = array('title' => $title, 'hmenu' => $hmenu); } else { $this->ajax = false; if (!is_null($file)) { echo '<div style="display: block; background-color: #FFFFFF; border: 2px solid #ff0000;">!!Man konnte in einer PHP Datei eine spezielle Index angeben. Damit das Design fuer diese Datei anders aussieht. Diese Funktion wurde ersetzt. Weitere Informationen im Forum auf ilch.de ... Thema: <a href="http://www.ilch.de/forum-showposts-13758-p1.html#108812">http://www.ilch.de/forum-showposts-13758-p1.html#108812</a></div>'; } $this->vars = array(); $this->file = $file; // setzte das file standard 0 weil durch was definiert $this->was = $was; // 0 = smalindex, 1 = normal index , 2 = admin $this->design = tpl::get_design(); $link = $this->htmlfile(); $this->headerAdds = ''; $this->bodyendAdds = ''; $tpl = new tpl($link, 2); if ($tpl->list_exists('boxleft')) { $tpl->set('boxleft', $this->get_boxes('l', $tpl)); } if ($tpl->list_exists('boxright')) { $tpl->set('boxright', $this->get_boxes('r', $tpl)); } // ab 0.6 = ... menu listen moeglich for ($i = 1; $i <= $allgAr['menu_anz']; $i++) { if ($tpl->list_exists('menunr' . $i)) { $tpl->set('menunr' . $i, $this->get_boxes($i, $tpl)); } } $ar = array('TITLE' => $this->escape_explode($title), 'HMENU' => '<span id="icHmenu">' . $this->escape_explode($hmenu) . '</span>', 'SITENAME' => $this->escape_explode($allgAr['title']), 'hmenuende' => '', 'vmenuende' => '', 'hmenubegi' => '', 'vmenubegi' => '', 'hmenupoint' => '', 'vmenupoint' => '', 'DESIGN' => $this->design); $tpl->set_ar($ar); $this->html = $tpl->get(0); $this->html .= '{EXPLODE}'; $this->html .= $tpl->get(1); unset($tpl); $zsave0 = array(); preg_match_all("/\\{_boxes_([^\\{\\}]+)\\}/", $this->html, $zsave0); $this->replace_boxes($zsave0[1]); unset($zsave0); $this->vars_replace(); unset($this->vars); $this->html = explode('{EXPLODE}', $this->html); } }
function test($params, $content, &$smarty, &$repeat) { if (!$repeat) { $v = tpl::get($smarty, 'ask'); return $params['ok'] . ":" . $content . $v; } }
/** * Вывод списка online-пользователей * @return null */ public function show_online() { $i = (int) config::o()->v('online_interval'); if (!$i) { $i = 15; } $time = time() - $i; $res = db::o()->p($time)->query('SELECT userdata FROM sessions WHERE time > ? GROUP BY IF(uid>0,uid,ip)'); $res = db::o()->fetch2array($res); tpl::o()->assign("res", $res); $c = count($res); $mo = stats::o()->read("max_online"); if (!intval($mo) || $mo < $c) { $mo = $c; stats::o()->write("max_online", $c); stats::o()->write("max_online_time", time()); } $mot = stats::o()->read("max_online_time"); tpl::o()->assign("record_total", $mo); tpl::o()->assign("record_time", $mot); /* @var $user user */ $user = plugins::o()->get_module("user"); lang::o()->get("profile"); tpl::o()->register_modifier("gau", array($user, "get_age")); tpl::o()->assign("bdl", $this->bd_list()); tpl::o()->display("blocks/contents/online.tpl"); }
/** * Редактирование пользователя * @param int $id ID пользователя * @return null */ protected function edit($id) { $id = (int) $id; lang::o()->get("registration"); lang::o()->get("usercp"); lang::o()->get('admin/groups'); /* @var $etc etc */ $etc = n("etc"); users::o()->set_tmpvars($etc->select_user($id)); if (users::o()->v('confirmed') != 3) { tpl::o()->assign('unco', true); } tpl::o()->assign('inusercp', true); /* @var $usercp usercp */ $usercp = plugins::o()->get_module('usercp'); /* @var $groups groups_man */ $groups = plugins::o()->get_module('groups', 1); ob_start(); $group = users::o()->get_group(users::o()->v('old_group') ? users::o()->v('old_group') : users::o()->v('group')); users::o()->alter_perms($group); $groups->add($group, false, true); $c = ob_get_contents(); ob_end_clean(); tpl::o()->assign('perms', $c); $usercp->show_index(); users::o()->remove_tmpvars(); }
public function __construct() { $endpoint = $this; if ($page = page('webmention') and kirby()->path() == $page->uri()) { if (r::is('post')) { try { $endpoint->start(); header::status(202); tpl::set('status', 'success'); tpl::set('alert', null); } catch (Exception $e) { header::status(400); tpl::set('status', 'error'); tpl::set('alert', $e->getMessage()); } } else { tpl::set('status', 'idle'); } } else { kirby()->routes(array(array('pattern' => 'webmention', 'method' => 'GET|POST', 'action' => function () use($endpoint) { try { $endpoint->start(); echo response::success('Yay', 202); } catch (Exception $e) { echo response::error($e->getMessage()); } }))); } }
/** * Функция отображения типов файлов * @return null */ protected function show() { $r = db::o()->query('SELECT * FROM allowed_ft'); tpl::o()->assign('res', db::o()->fetch2array($r)); tpl::o()->register_modifier('aftbasic', array($this, 'is_basic')); tpl::o()->display('admin/allowedft/index.tpl'); }
static function get_instance() { if (!(isset(self::$object) && self::$object instanceof Smarty)) { self::$object = new Smarty(); } return isset(self::$object) ? self::$object : null; }
/** * Функция отображения доп. полей * @return null */ protected function show() { $r = db::o()->query('SELECT * FROM users_fields'); tpl::o()->assign('res', db::o()->fetch2array($r)); tpl::o()->register_modifier('cut_type_descr', array($this, 'cut_type_descr')); tpl::o()->display('admin/userfields/index.tpl'); }
/** * Embeds a snippet from the snippet folder * * @param string $file * @param mixed $data array or object * @param boolean $return * @return string */ function snippet($file, $data = array(), $return = false) { if (is_object($data)) { $data = array('item' => $data); } return tpl::load(c::get('root.snippets') . DS . $file . '.php', $data, $return); }
/** * Renders the snippet with the given data * * @param string $name * @param array $data * @param boolean $return * @return string */ public function render($name, $data = [], $return = false) { if (is_object($data)) { $data = ['item' => $data]; } return tpl::load($this->kirby->registry->get('snippet', $name), $data, $return); }
function search_finduser() { $design = new design('Finduser', '', 0); $design->header(); $tpl = new tpl('search_finduser'); $tpl->out(0); if (isset($_POST['sub']) and !empty($_POST['name'])) { $name = str_replace('*', "%", $_POST['name']); $name = escape($name, 'string'); $q = "SELECT `name`,`name` FROM `prefix_user` WHERE `name` LIKE '" . $name . "'"; $tpl->set('username', dbliste('', $tpl, 'username', $q)); $tpl->out(1); } $tpl->out(2); $design->footer(); }
/** * Embeds a snippet from the snippet folder * * @param string $file * @param mixed $data array or object * @param boolean $return * @return string */ function snippet($file, $data = array(), $return = false) { if (is_object($data)) { $data = array('item' => $data); } return tpl::load(kirby::instance()->roots()->snippets() . DS . $file . '.php', $data, $return); }
/** * Отображение списка обратной связи * @param string $sort сортировка * @param string $type тип * @return null */ protected function show($sort = null, $type = '') { $orderby = ''; if ($sort) { $sort = explode(",", $sort); $c = count($sort); for ($i = 0; $i < $c; $i += 2) { if (!$this->orderby[$sort[$i]]) { continue; } $orderby .= ($orderby ? ', ' : '') . "`" . $this->orderby[$sort[$i]] . "` " . ($sort[$i + 1] ? "asc" : "desc"); } } if (!$orderby) { $orderby = 'f.`time` DESC'; } $where = $type ? 'f.type=?' : ""; $count = db::o()->p($type)->as_table('f')->count_rows("feedback", $where); list($pages, $limit) = display::o()->pages($count, config::o()->v('table_perpage'), 'switch_feedback_page', 'page', 5, true); $r = db::o()->p($type)->query('SELECT f.*, u.username, u.group FROM feedback AS f LEFT JOIN users AS u ON u.id=f.uid ' . ($where ? ' WHERE ' . $where : "") . ' ' . ($orderby ? ' ORDER BY ' . $orderby : "") . ' ' . ($limit ? ' LIMIT ' . $limit : "")); tpl::o()->assign('res', db::o()->fetch2array($r)); tpl::o()->assign('pages', $pages); tpl::o()->assign('type', $type); tpl::o()->display('admin/feedback/index.tpl'); }
/** * Отображение списка логов * @param string $type тип логов * @param string $sort сортировка * @return null */ protected function show($type = null, $sort = null) { tpl::o()->assign('curtype', $type); $orderby = ''; if ($sort) { $sort = explode(",", $sort); $c = count($sort); for ($i = 0; $i < $c; $i += 2) { if (!$this->orderby[$sort[$i]]) { continue; } $orderby .= ($orderby ? ', ' : '') . "`" . $this->orderby[$sort[$i]] . "` " . ($sort[$i + 1] ? "asc" : "desc"); } } if (!$orderby) { $orderby = 'l.`time` DESC'; } $count = db::o()->p($type)->count_rows("logs", $type ? 'type=?' : ""); list($pages, $limit) = display::o()->pages($count, config::o()->v('table_perpage'), 'switch_logs_page', 'page', 5, true); $r = db::o()->p($type)->query('SELECT l.*, u.username, u.group, u2.username AS tusername, u2.group AS tgroup FROM logs AS l LEFT JOIN users AS u ON u.id=l.byuid LEFT JOIN users AS u2 ON u2.id=l.touid ' . ($type ? ' WHERE l.type=?' : "") . ' ' . ($orderby ? ' ORDER BY ' . $orderby : "") . ' ' . ($limit ? ' LIMIT ' . $limit : "")); tpl::o()->assign('res', db::o()->fetch2array($r)); tpl::o()->assign('log_types', $this->types); tpl::o()->assign('pages', $pages); tpl::o()->display('admin/logs/index.tpl'); }
function smarty_modifier_date_format3($sDatetime, $sFormat = false) { //get datetime if (!$sDatetime) { return ''; } return tpl::date_format3($sDatetime, $sFormat); }
static function set($key, $value = false) { if (is_array($key)) { self::$vars = array_merge(self::$vars, $key); } else { self::$vars[$key] = $value; } }
/** * 控制器构造函数 * * 当子类实现自己的控制器构造函数时,必须在构造函数体内第一行调用: parent::__construct(); */ function __construct() { global $__core_env; $rand = rand(1000, 9999); $__core_env['__LIUSHUIHAO__'] = time() . $UID . $rand; $this->__out =& $__core_env['out']; $this->_tpl = tpl::singleton(); }
public function toHtml() { $snippet = kirby()->roots()->snippets() . DS . 'webmentions' . DS . 'author.php'; if (!file_exists($snippet)) { $snippet = dirname(__DIR__) . DS . 'snippets' . DS . 'author.php'; } return tpl::load($snippet, array('author' => $this, 'mention' => $this->mention)); }
public function render() { $file = $this->_root . DS . str_replace('.', DS, $this->_file) . '.php'; if (!file_exists($file)) { throw new Exception(l('view.error.invalid') . $file); } return tpl::load($file, $this->_data); }
function show() { global $app, $conf; //* Loading Template $app->uses('tpl'); $tpl = new tpl(); $tpl->newTemplate("dashlets/templates/modules.htm"); $wb = array(); $lng_file = 'lib/lang/' . $_SESSION['s']['language'] . '_dashlet_modules.lng'; if (is_file($lng_file)) { include $lng_file; } $tpl->setVar($wb); /* * Show all modules, the user is allowed to use */ $modules = explode(',', $_SESSION['s']['user']['modules']); $mod = array(); if (is_array($modules)) { foreach ($modules as $mt) { if (is_file('../' . $mt . '/lib/module.conf.php')) { if (!preg_match("/^[a-z]{2,20}\$/i", $mt)) { die('module name contains unallowed chars.'); } include_once '../' . $mt . '/lib/module.conf.php'; /* We don't want to show the dashboard */ if ($mt != 'dashboard') { $module_title = $app->lng($module['title']); if (function_exists('mb_strlen')) { if (mb_strlen($module_title, "UTF-8") > 8) { $module_title = mb_substr($module_title, 0, 7, "UTF-8") . '..'; } } else { if (strlen($module_title) > 8) { $module_title = substr($module_title, 0, 7) . '..'; } } $mod[] = array('modules_title' => $module_title, 'modules_startpage' => $module['startpage'], 'modules_name' => $module['name']); } } } $tpl->setloop('modules', $mod); } return $tpl->grab(); }
static function head($params, $tpl) { $data['script'] = $data['group_script'] = $data['style'] = $data['group_style'] = null; isset($params['script']) && ($data['script'] = explode('|', $params['script'])); isset($params['group_script']) && ($data['group_script'] = explode('|', $params['group_script'])); isset($params['style']) && ($data['style'] = explode('|', $params['style'])); isset($params['group_style']) && ($data['group_style'] = explode('|', $params['group_style'])); return tpl::show('plugin/head', $data, $tpl); }
function sharchiv() { $tpl = new tpl('shbox4', 0); echo '<div> <h4 align="center" class="Chead">' . $this->version . ' Archiv</h4> </div>'; $erg = db_query('SELECT * FROM `prefix_shbox4` ORDER BY `id` DESC'); while ($row = db_fetch_assoc($erg)) { $text = $row['txt']; $text = $this->shtext($text); $ar = array('AUSGABE' => '<p class="Cdark" style="margin:0;">' . $this->shdate($row['time'], $row['uid']) . '</p> <p class="Cnorm" style="margin:0;">' . $this->colortext($this->sh_usercheck($row['uid']), $text) . '</p> <br />'); $tpl->set_ar_out($ar, 2); } $tpl->set_ar(array('VERS' => $this->version())); $tpl->out(3); }
public function __construct() { //视图初始化 $this->tpl = tpl::getInstance(C('tpl')); //预留初始化 if (method_exists($this, 'init')) { $this->init(); } }
static function flv($params, $tpl) { $data['src'] = isset($params['src']) ? $params['src'] : ''; $data['width'] = isset($params['width']) ? $params['width'] : 600; $data['height'] = isset($params['height']) ? $params['height'] : 450; $data['autostart'] = $data['allowfullscreen'] = 'false'; isset($params['autostart']) && ($data['autostart'] = $params['autostart']); isset($params['allowfullscreen']) && ($data['allowfullscreen'] = $params['allowfullscreen']); return tpl::show('plugin/flv', $data, $tpl); }