function spp_random_terms_func($atts) { extract(shortcode_atts(array('count' => 10), $atts)); global $spp_settings; global $wpdb; // SELECT * FROM myTable WHERE RAND()<(SELECT ((30/COUNT(*))*10) FROM myTable) ORDER BY RAND() LIMIT 30; $sql = "SELECT `term` FROM `" . $wpdb->prefix . "spp` WHERE RAND()<(SELECT ((" . $count . "/COUNT(`term`))*10) FROM `" . $wpdb->prefix . "spp`) ORDER BY RAND() LIMIT " . $count . ";"; $searchterms = $wpdb->get_results($sql); if (!empty($searchterms) && count($searchterms) > 100) { $terms = array(); foreach ($searchterms as $term) { $terms[] = $term->term; } } else { $file = @file_get_contents(SPP_PATH . '/keywords.txt'); if ($file) { $terms = explode("\n", $file); shuffle($terms); $terms = array_slice($terms, 0, $count); } else { $terms = array(); } } $result = new h2o(SPP_PATH . "/templates/widget.html"); return $result->render(array('terms' => $terms, 'settings' => $spp_settings)); }
/** * Render template with variables for sending in an email * * @param $template * @param $page * @return string */ static function renderEmail($template, $page) { // H2o object for rendering $h2o = new h2o(null, array('autoescape' => false)); // Load template and render it $h2o->loadTemplate(__DIR__ . '/../views/' . $template); return $h2o->render(compact('page')); }
function renderException($data, $template = "") { if (DEBUG) { $template = "exception.html"; $template_paths = array(dirname(__FILE__) . '/templates/'); $h2o = new h2o($template, array('searchpath' => $template_paths, 'cache' => false)); echo $h2o->render($data); } else { } }
public function render($template, $vars) { $registry = Registry::getInstance(); require_once join_path($registry->web_root, 'system/template/h2o.php'); $path = join_path($registry->web_root, 'view/' . $template . '.html'); if (!file_exists($path)) { trigger_error('Template: View ' . $path . ' not found!'); } $vars = array_merge($vars, array('config' => $registry)); $h2o = new h2o($path, array('cache' => 'apc', 'safeClass' => array('V7F\\Helpers\\Registry', 'V7F\\Template\\Template_Helpers'))); echo $h2o->render($vars); }
public function render() { if (!isset($_COOKIE['lang'])) { $lang = 'fr'; } else { $lang = $_COOKIE['lang']; } $h2o = new h2o($this->template, array('searchpath' => 'templates', 'php-i18n' => array('locale' => $lang, 'charset' => 'UTF-8', 'gettext_path' => '/usr/bin/', 'tmp_dir' => '/tmp/'))); //$session = get_session(); //$logged = $session->get_logged_user(); $globals = array('lang' => $lang, 'IMG_URL' => IMG_URL); return $h2o->render(array_merge($globals, $this->datas)); }
function spp_random_terms_func($atts) { extract(shortcode_atts(array('count' => 10), $atts)); global $spp_settings; global $wpdb; // SELECT * FROM myTable WHERE RAND()<(SELECT ((30/COUNT(*))*10) FROM myTable) ORDER BY RAND() LIMIT 30; $sql = "SELECT `term` FROM `" . $wpdb->prefix . "spp` WHERE RAND()<(SELECT ((" . $count . "/COUNT(`term`))*10) FROM `" . $wpdb->prefix . "spp`) ORDER BY RAND() LIMIT " . $count . ";"; $searchterms = $wpdb->get_results($sql); if (!empty($searchterms)) { $result = new h2o(SPP_PATH . "/templates/widget.html"); return $result->render(array('terms' => $searchterms, 'settings' => $spp_settings)); } else { return false; } }
function renderPage($template) { $content = ''; foreach ($template as $key => $value) { // try to mitigate directory traversal and remote inclusion if (preg_match('/[^a-zA-Z0-9\\.]/', $template[$key]['name'])) { die; } $_file = TEMPLATES_DIR . str_replace('.', '/', $template[$key]['name']) . '.html'; // render the content template $page = new h2o($_file); $content .= $page->render($template[$key]['vars']); unset($page); } // place templates into the context of the main page $index = new h2o(TEMPLATES_DIR . 'index.html'); echo $index->render(array('content' => $content, 'user' => $_SESSION['user'])); exit; }
function spp($term = "", $template = 'default.html', $hack = "") { global $spp_settings; $result = new h2o(SPP_PATH . "/templates/{$template}", array('safeClass' => array('SimpleXMLElement', 'stdClass'))); return $result->render(array('term' => $term, 'hack' => $hack, 'settings' => $spp_settings)); }
require 'h2o/h2o.php'; $h2o = new h2o('templates/friends.html'); $user = $_COOKIE['email']; $hash = $_COOKIE['crypt']; if (crypt($user, $hash) == $hash) { } else { header("Location:logout.php"); } $data = array('error' => '', 'email' => $user); #$data['email']=$user require 'config.php'; require 'connect.php'; $ret = mysql_query("SELECT email from incoming where destination='{$user}'"); if (mysql_error($conn)) { $data['error'] = mysql_error($conn); echo $h2o->render(compact('data')); return; } while ($row = mysql_fetch_assoc($ret)) { $json[] = $row; } $ret = mysql_query("SELECT DISTINCT email2 as email from connections where email1='{$user}' and email2<>'{$user}'"); while ($row = mysql_fetch_assoc($ret)) { $json1[] = $row; } $ret = mysql_query("SELECT email FROM users WHERE email NOT IN ( SELECT email2 FROM connections WHERE email1='{$user}') and email<>'{$user}'") or die(mysql_error()); while ($row = mysql_fetch_assoc($ret)) { $json2[] = $row; } echo $h2o->render(compact('data', 'json', 'json1', 'json2'));
<?php require 'h2o/h2o.php'; $h2o = new h2o('templates/index.html'); $data = array('error' => ''); if (isset($_REQUEST['email'])) { require 'config.php'; require 'connect.php'; $email = htmlspecialchars($_REQUEST['email']); $password = htmlspecialchars($_REQUEST['password']); $ret = mysql_query("SELECT password from users where email='{$email}'"); if (mysql_error($conn)) { $data['error'] = mysql_error($conn); echo $h2o->render(compact('data')); return; } $crypt = crypt($email); while ($row = mysql_fetch_assoc($ret)) { if (crypt($password, $row['password']) == $row['password']) { } else { $data['error'] = "Password Error"; echo $h2o->render(compact('data')); return; } setcookie("email", $email, time() + 3600, "/"); setcookie("crypt", $crypt, time() + 3600, "/"); header("Location:/home.php"); return; } $data['error'] = "Not Found : Please Register"; echo $h2o->render(compact('data'));
/** * Handles rendering the header, footer, content and initialising the page * * @param $parameters * @return string */ function superHandler($parameters) { // Set our controller and view directories $controllerDirectory = __DIR__ . '/../controllers/'; $viewDirectory = __DIR__ . '/../views/'; // Initialise our page array $page = Session::init($parameters['title'], $parameters['flashes'], $parameters['restricted']); // if parameters are passed, then add them if (array_key_exists('parameters', $parameters)) { $page['parameters'] = $parameters['parameters']; } // Require our controller require $controllerDirectory . $parameters['controller']; // Initialise our h2o object $h2o = new h2o(null, array('autoescape' => false)); $output = ""; if (array_key_exists('header', $parameters) && $parameters['header'] == true) { $h2o->loadTemplate($viewDirectory . 'global/header.html'); $output .= $h2o->render(compact('page')); } if ($parameters['view'] != null) { $h2o->loadTemplate($viewDirectory . $parameters['view']); $output .= $h2o->render(compact('page')); } if (array_key_exists('footer', $parameters) && $parameters['footer'] == true) { $h2o->loadTemplate($viewDirectory . 'global/footer.html'); $output .= $h2o->render(compact('page')); } // return output return $output; }
public function should_be_able_to_output_parent_template_using_blog_super() { $h2o = new h2o('home', $this->option); expects($h2o->render())->should_be('depth: 2- parent content, depth: 1- child content'); }
<?php include 'init.php'; $h2o = new h2o('templates/b2_filters_tpl.html'); $objects = array(); for ($i = 0; $i < 100; $i++) { $o = new stdClass(); $o->i = $i; $o->epoch = (int) time(); array_push($objects, $o); } echo $h2o->render(compact('objects'));
* * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of the nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * */ if (!defined('IN_RECOVERY')) { die; } $content = new contentClass(); $posts = $content->getFrontPage(MAX_NEWS_POSTS, USE_CACHING ? CACHE_DIR : NULL); $contentTemplate = new h2o(TEMPLATES_DIR . 'post/main.html'); $index = new h2o(TEMPLATES_DIR . 'index.html'); echo $index->render(array('content' => $contentTemplate->render(compact('posts')), 'user' => $_SESSION['user']));
require 'vendor/autoload.php'; /** * Let the provisioner automatically intervene and reconfigure Apache. This only * happens when users try to access a domain that Apache isn't aware off yet and * the provisioner will then - just in time - install vhost files and reload. */ \LXC\VirtualHost\ApacheProvisioner::check('root', 'root', 'templates/rebuilding.html', 'templates/vhost.conf'); /** * Configure the router. */ $router = new \Bramus\Router\Router(); $t = new \h2o(); # ROUTE /: index listing. $router->get('/', function () use($t) { $t->loadTemplate('templates/listing.html'); print $t->render(array('lxc' => \LXC\Container\Variables::get(), 'vhosts' => \LXC\VirtualHost\Listing::get(), 'hostsoutdated' => \LXC\VirtualHost\Listing::are_hosts_outdated(), 'logfiles' => \LXC\Logging\Files::get(), 'hostname' => gethostname())); }); # ROUTE /php: PHP information. $router->get('/php', function () { phpinfo(); }); # ROUTE /$LOGFILE: tail -f style log viewer. foreach (\LXC\Logging\Files::get() as $logfile) { $path = '/' . $logfile->name; $router->get($path, function () use($t, $logfile) { $t->loadTemplate('templates/logtail.html'); print $t->render(array('file' => $logfile, 'lxc' => \LXC\Container\Variables::get(), 'hostname' => gethostname())); }); $router->get($path . '/(\\d+)', function ($from_line) use($t, $logfile) { $logfile->sendPayload((int) $from_line); });
function renderTemplate($templateName) { $currentSkin = $this->currentSkin(); if (!file_exists(dirname($this->_file()) . '/skins/' . $currentSkin . '/templates/' . $templateName . '.html')) { $currentSkin = "default"; } $filePath = dirname($this->_file()) . '/skins/' . $currentSkin . '/templates/' . $templateName . '.html'; $options = array("cache_dir" => dirname($this->_file()) . '/lava/_cache/'); $h2o = new h2o($filePath, $options); $templateVars = apply_filters($this->_slug("_templateVars"), array()); return $h2o->render($templateVars); }
<?php include 'init.php'; $h2o = new h2o('templates/b1_tpl.html'); $objects = array(); for ($i = 0; $i < 100; $i++) { $epoch = time(); echo $h2o->render(compact('i', 'epoch')); }
public function GET() { $view = new h2o('views/index.html'); $person = array('name' => 'Mathew'); echo $view->render(compact('person')); }
<?php include 'init.php'; $title = "Cabecera menéame"; $globals = array(); $globals['favicon'] = "icon.jpg"; $globals['noindex'] = True; $globals['tags'] = 'test1, test2'; $globals['description'] = 'Pruebas de descripción'; $globals['server_name'] = 'www.meneame.net'; $globals['base_url'] = '/'; $globals['base_static'] = 'http://static.meneame.net'; $globals['js_main'] = 'general01.php'; $globals['security_key'] = 'xxxxxxxxxxxxxxxxxxxxxxx'; $globals['thumbnail'] = 'void.jpg'; $globals['thumbnail_logo'] = 'void.jpg'; $globals['extra_head'] = ''; $globals['extra_js'] = array('void.js', 'void1.js'); $globals['q'] = 'q=aslkdlñak ñlsakd ñlaks&kasjlkadjlajsdljkl'; $globals['lang'] = 'es'; $globals['css_main'] = 'main.css'; $globals['css_color'] = 'main.css'; $h2o = new h2o('templates/header.html'); echo $h2o->render(compact('globals', 'title')); echo $h2o->render(compact('globals', 'title')); echo $h2o->render(compact('globals', 'title'));