Exemple #1
0
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));
}
Exemple #2
0
 /**
  * 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'));
 }
Exemple #3
0
 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);
 }
Exemple #5
0
 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));
 }
Exemple #6
0
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;
    }
}
Exemple #7
0
 function __construct($file = '', $options = array())
 {
     # Init a environment
     $this->options = $this->getOptions($options);
     $loader = $this->options['loader'];
     if (!$loader) {
         return true;
     }
     if (is_object($loader)) {
         $this->loader = $loader;
         $this->loader->setOptions($this->options);
     } else {
         $loaderClass = "H2o_{$loader}_Loader";
         if (!class_exists($loaderClass)) {
             throw new Exception('Invalid template loader');
         }
         if (isset($options['searchpath'])) {
             $this->searchpath = realpath($options['searchpath']) . DS;
         } else {
             $this->searchpath = dirname(realpath($file)) . DS;
         }
         $this->loader = new $loaderClass($this->searchpath, $this->options);
     }
     if (isset($options['i18n'])) {
         $i18n_options = array();
         if (is_array($options['i18n'])) {
             $i18n_options = $options['i18n'];
         }
         h2o::load('i18n');
         $this->i18n = new H2o_I18n($this->searchpath, $i18n_options);
     }
     $this->loader->runtime = $this;
     $this->nodelist = $this->loadTemplate($file);
 }
Exemple #8
0
 function __construct($file = null, $options = array())
 {
     # Init a environment
     $this->options = $this->getOptions($options);
     $loader = $this->options['loader'];
     if (!$loader) {
         return true;
     }
     if (is_object($loader)) {
         $this->loader = $loader;
         $this->loader->setOptions($this->options);
     } else {
         $loader = __NAMESPACE__ . '\\' . "H2o_{$loader}_Loader";
         if (!class_exists($loader)) {
             throw new \Exception('Invalid template loader');
         }
         if (isset($options['searchpath'])) {
             $this->searchpath = realpath($options['searchpath']) . DS;
         } elseif ($file) {
             $this->searchpath = dirname(realpath($file)) . DS;
         } else {
             $this->searchpath = getcwd() . DS;
         }
         $this->loader = new $loader($this->searchpath, $this->options);
     }
     $this->loader->runtime = $this;
     if (isset($options['i18n'])) {
         h2o::load('i18n');
         $this->i18n = new H2o_I18n($this->searchpath, $options['i18n']);
     }
     if ($file) {
         $this->nodelist = $this->loadTemplate($file);
     }
 }
Exemple #9
0
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;
}
Exemple #10
0
    {
        if (!empty($argstring) && !preg_match($this->syntax, $argstring)) {
            throw TemplateSyntaxError('Please specify time to live value for this cache block');
        }
        $this->body = $parser->parse('endcache');
        $this->uid = md5($parser->filename . $pos);
        $this->ttl = (int) $argstring;
        $options = $parser->options;
        if ($this->ttl) {
            $options['cache_ttl'] = $this->ttl;
        }
        if (!$options['cache']) {
            $options['cache'] = 'file';
        }
        $this->cache = h2o_cache($options);
    }
    function render($context, $stream)
    {
        if ($output = $this->cache->read($this->uid)) {
            $stream->write($output);
            return;
        }
        $output = new StreamWriter();
        $this->body->render($context, $output);
        $output = $output->close();
        $this->cache->write($this->uid, $output);
        $stream->write($output);
    }
}
h2o::addTag('cache');
Exemple #11
0
        $hack = $context->resolve(':hack');
        $url = $this->get_api_url($term, $hack);
        $feed = @$this->fetch($context, $url)->xpath('//channel/item');
        $feed = @$this->filter($feed);
        $context->set("api", $feed);
        $context->set("api_url", $url);
    }
}
h2o::addTag('api');
function filter_bad_words($content)
{
    global $spp_settings;
    $bad_words = explode(',', $spp_settings->bad_words);
    foreach ($bad_words as $word) {
        // mulai ubah konten
        $content = str_ireplace($word . ' ', '', $content);
        $content = str_ireplace(' ' . $word . ' ', '', $content);
        $content = str_ireplace(' ' . $word, '', $content);
        $content = str_ireplace($word, '.', $content);
        $content = str_ireplace($word, ',', $content);
        $content = str_ireplace($word, '-', $content);
    }
    return $content;
}
h2o::addFilter('filter_bad_words');
function remove_repeating_chars($object)
{
    return preg_replace("/[^a-zA-Z0-9\\s.?!\\/]/", "", $object);
}
h2o::addFilter('remove_repeating_chars');
Exemple #12
0
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));
}
Exemple #13
0
<?php

class TimelineFilters extends FilterCollection
{
    static function userify($user, $timelineid, $suffix = null)
    {
        if (!$user['deleted']) {
            return sprintf('<span class="a" onclick="showUserInfo(%d, null, {source: \'timeline\', timeline_id: %d})">%s %s</span>', $user['id'], $timelineid, $user['name'], $user['surname']) . $suffix;
        } else {
            return $user['name'] . " " . $user['surname'] . $suffix;
        }
    }
    static function user_adjectify($user, $timelineid)
    {
        $is_comment = array_key_exists('commenter_id', $user);
        if ($is_comment) {
            $suffix = "'s";
        } else {
            $suffix = null;
        }
        if (!$is_comment || $user['id'] != $user['commenter_id']) {
            return TimelineFilters::userify($user, $timelineid, $suffix);
        } else {
            return $user['adj'];
        }
    }
}
h2o::addFilter(array('TimelineFilters'));
Exemple #14
0
<?php

print_r(memory_get_usage());
include '../h2o.php';
h2o::load('i18n');
//// Set language to German
//$i18n = new H2o_I18n(dirname(__FILE__).DS, array(
//    'gettext_path' => dirname(__FILE__).DS.'bin/gettext/bin/'
//));
//$i18n->setLocale('fr');
//
//$i18n->extract();
//$i18n->compile();
////
// Choose domain
//extract_translations(
//   realpath('trans.tpl'), array('tpl', 'html'), dirname(__FILE__).DS.'bin/gettext/bin/'
//);
//
//compile_translations(
//   realpath('trans.tpl'), null, dirname(__FILE__).DS.'bin/gettext/bin/'
//);
$template = new H2o('trans.tpl', array('cache' => false, 'cache_dir' => dirname(__FILE__)));
$time_start = microtime(true);
for ($i = 0; $i < 10; $i++) {
    $r = $template->render(array('users' => array(array('username' => 'peter', 'tasks' => array('school', 'writing'), 'user_id' => 1), array('username' => 'anton', 'tasks' => array('go shopping'), 'user_id' => 2), array('username' => 'john doe', 'tasks' => array('write report', 'call tony', 'meeting with arron'), 'user_id' => 3), array('username' => 'foobar', 'tasks' => array(), 'user_id' => 4))));
}
echo $r;
echo "in " . (microtime(true) - $time_start) . " seconds\n<br/>";
    return str_replace($search, '', $term);
}
if (function_exists('wpunique_synonymize')) {
    h2o::addFilter('wpunique_synonymize');
}
h2o::addFilter('host');
function host($string)
{
    $host = parse_url($string);
    return $host['host'];
}
function spp_shortcode($atts)
{
    extract(shortcode_atts(array('term' => 'hello world', 'template' => 'default.html', 'hack' => ''), $atts));
    return spp($term, $template, $hack);
}
add_shortcode('spp', 'spp_shortcode');
function get_video_id($url)
{
    $parts = parse_url($url);
    if ($parts === false) {
        return false;
    } else {
        parse_str($parts['query'], $params);
        return $params['v'];
    }
}
h2o::addFilter('get_video_id');
if (!class_exists('h2o_parser')) {
    require SPP_PATH . '/templates/h2o/h2o/parser.php';
}
<?php

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;
}
Exemple #17
0
<?php

# For compatibility with Django.
class Admin_media_prefix_Tag extends H2o_Node
{
    function render($context, $stream)
    {
        $stream->write("/media/");
    }
}
h2o::addTag('admin_media_prefix');
Exemple #18
0
        return $before;
    }
}
h2o::addFilter('firstword');
function build_permalink_for($term, $url_rewrites_index)
{
    global $spp_settings;
    $rule = $spp_settings->url_rewrites[$url_rewrites_index];
    $term = CoreFilters::hyphenize($term);
    $term = str_replace('-', $rule['separator'], $term);
    $array_of_term = explode($rule['separator'], $term);
    $first_word = isset($array_of_term[0]) ? $array_of_term[0] : $term;
    $permalink = $rule['permalink'];
    $permalink = str_replace('{{ first_word }}', $first_word, $permalink);
    $permalink = str_replace('{{ random }}', substr(md5($term), 1, 7), $permalink);
    $permalink = str_replace('{{ term }}', $term, $permalink);
    $permalink = home_url($permalink);
    return $permalink;
}
h2o::addFilter('build_permalink_for');
h2o::addFilter('base64_encode');
function spp_is_bot()
{
    $crawlers = array('aspseek', 'abachobot', 'accoona', 'acoirobot', 'adsbot', 'alexa', 'alta vista', 'altavista', 'ask jeeves', 'baidu', 'bing', 'crawler', 'croccrawler', 'dumbot', 'estyle', 'exabot', 'fast-enterprise', 'fast-webcrawler', 'francis', 'geonabot', 'gigabot', 'google', 'googlebot', 'heise', 'heritrix', 'ibm', 'iccrawler', 'idbot', 'ichiro', 'lycos', 'mediapartners-google', 'msn', 'msrbot', 'majestic-12', 'metager', 'ng-search', 'nutch', 'omniexplorer', 'psbot', 'rambler', 'seosearch', 'scooter', 'scrubby', 'seekport', 'sensis', 'seoma', 'snappy', 'steeler', 'synoo', 'telekom', 'turnitinbot', 'voyager', 'wisenut', 'yacy', 'yahoo');
    foreach ($crawlers as $c) {
        if (stripos($_SERVER['HTTP_USER_AGENT'], $c) !== false) {
            return true;
        }
    }
    return false;
}
Exemple #19
0
function templize($source)
{
    $output = array();
    $inline_re = '/^\\s*trans\\s+("(?:[^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'(?:[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')\\s*/';
    $block_re = "/^\\s*blocktrans(?:\\s+|\$)/";
    $endblock_re = "/^\\s*endblocktrans\$/";
    $plural_re = "/^\\s*plural\$/";
    $var_re = '{
        _\\(
            (
            "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" |   # Double Quote string   
            \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' # Single Quote String
            )
        \\)
    }x';
    $lexer = new H2o_Lexer(h2o::getOptions());
    $tokenstream = $lexer->tokenize($source);
    $in_block = false;
    $is_plural = false;
    $singulars = array();
    $plurals = array();
    while ($t = $tokenstream->next()) {
        if ($in_block) {
            if ($t->type == 'block' && $t->content == 'endblocktrans') {
                if ($is_plural) {
                    $output[] = sprintf(" ngettext('%s', '%s', \$count)", join('', $singulars), join('', $plurals));
                } else {
                    $output[] = sprintf(" gettext('%s')", join('', $singulars));
                }
                $singulars = $plurals = array();
                $in_block = $is_plural = false;
            } elseif ($t->type == 'block' && $t->content == 'plural') {
                $is_plural = true;
            } elseif ($t->type == 'text') {
                if ($is_plural) {
                    $plurals[] = addslashes($t->content);
                } else {
                    $singulars[] = addslashes($t->content);
                }
            } elseif ($t->type == 'variable') {
                @(list($var, $filters) = explode('|', $t->content));
                if ($is_plural) {
                    $plurals[] = sprintf("%%(%s)", $var);
                } else {
                    $singulars[] = sprintf("%%(%s)", $var);
                }
            } elseif ($t->type == 'block') {
                throw new Exception('No block tag is allowed in translation block');
            }
        } else {
            if ($t->type == 'block') {
                if (preg_match($inline_re, $t->content, $matches)) {
                    $output[] = sprintf(" gettext(%s)", $matches[1]);
                } elseif (preg_match($block_re, $t->content, $matches)) {
                    $in_block = true;
                }
            } elseif ($t->type == 'variable') {
                if (preg_match($var_re, $t->content, $matches)) {
                    $output[] = sprintf(" gettext(%s)", $matches[1]);
                }
            }
        }
    }
    $result = str_replace("\r", '', implode(";\n", $output));
    if ($result) {
        return "\n" . $result . ";\n";
    }
}
Exemple #20
0
<?php

class Site_Tag extends Tag
{
    function render($context, $stream)
    {
        $stream->write('This is my site');
    }
}
h2o::addTag('site');
Exemple #21
0
                        if (method_exists($obj, $attribute)) {
                            $obj = call_user_func_array(array($obj, $attribute), array());
                        } else {
                            if (method_exists($obj, "get_" . $attribute)) {
                                $obj = call_user_func_array(array($obj, "get_" . $attribute), array());
                            } else {
                                if (method_exists($obj, "is_" . $attribute)) {
                                    $obj = call_user_func_array(array($obj, "is_" . $attribute), array());
                                } else {
                                    $obj = null;
                                }
                            }
                        }
                    }
                } else {
                    $obj = null;
                    break;
                }
            }
        }
    }
    return $obj;
}
h2o::addTag(array("sqlvalue"));
h2o::addTag(array("sparqlvalue"));
h2o::addTag(array("tplnotice"));
h2o::addFilter(array('pmb_StringFilters'));
h2o::addFilter(array('pmb_DateFilters'));
H2o::addLookup("messagesLookup");
H2o::addLookup("globalLookup");
H2o::addLookup("recursive_lookup");
Exemple #22
0
/**
 * 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;
}
Exemple #23
0
        }
        return $images;
    }
    function render($context, $stream)
    {
        $cache = h2o_cache($context->options);
        $term = $context->resolve(':term');
        $hack = $context->resolve(':hack');
        $url = $this->get_api_url($term, $hack);
        $feed = @$this->fetch($context, $url);
        $feed = @$this->filter($feed);
        $context->set("images", $feed);
        $context->set("is_single_image", $this->is_single_image());
    }
    function fix_json($j)
    {
        $j = trim($j);
        $j = ltrim($j, '(');
        $j = rtrim($j, ')');
        $a = preg_split('#(?<!\\\\)\\"#', $j);
        for ($i = 0; $i < count($a); $i += 2) {
            $s = $a[$i];
            $s = preg_replace('#([^\\s\\[\\]\\{\\}\\:\\,]+):#', '"\\1":', $s);
            $a[$i] = $s;
        }
        $j = implode('"', $a);
        return $j;
    }
}
h2o::addTag('image');
Exemple #24
0
<?php

//thanks to brokencode
//@jisportal http://www.jisportal.com/forum/showthread.php/7133-Memanfaatkan-Halaman-Category-dan-Tag-pada-WordPress/page4?highlight=common+words
function remove_common_words($input)
{
    $commonWords = array('a', 'able', 'about', 'above', 'abroad', 'according', 'accordingly', 'across', 'actually', 'adj', 'after', 'afterwards', 'again', 'against', 'ago', 'ahead', 'ain\'t', 'all', 'allow', 'allows', 'almost', 'alone', 'along', 'alongside', 'already', 'also', 'although', 'always', 'am', 'amid', 'amidst', 'among', 'amongst', 'an', 'and', 'another', 'any', 'anybody', 'anyhow', 'anyone', 'anything', 'anyway', 'anyways', 'anywhere', 'apart', 'appear', 'appreciate', 'appropriate', 'are', 'aren\'t', 'around', 'as', 'a\'s', 'aside', 'ask', 'asking', 'associated', 'at', 'available', 'away', 'awfully', 'b', 'back', 'backward', 'backwards', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'begin', 'behind', 'being', 'believe', 'below', 'beside', 'besides', 'best', 'better', 'between', 'beyond', 'both', 'brief', 'but', 'by', 'c', 'came', 'can', 'cannot', 'cant', 'can\'t', 'caption', 'cause', 'causes', 'certain', 'certainly', 'changes', 'clearly', 'c\'mon', 'co', 'co.', 'com', 'come', 'comes', 'concerning', 'consequently', 'consider', 'considering', 'contain', 'containing', 'contains', 'corresponding', 'could', 'couldn\'t', 'course', 'c\'s', 'currently', 'd', 'dare', 'daren\'t', 'definitely', 'described', 'despite', 'did', 'didn\'t', 'different', 'directly', 'do', 'does', 'doesn\'t', 'doing', 'done', 'don\'t', 'down', 'downwards', 'during', 'e', 'each', 'edu', 'eg', 'eight', 'eighty', 'either', 'else', 'elsewhere', 'end', 'ending', 'enough', 'entirely', 'especially', 'et', 'etc', 'even', 'ever', 'evermore', 'every', 'everybody', 'everyone', 'everything', 'everywhere', 'ex', 'exactly', 'example', 'except', 'f', 'fairly', 'far', 'farther', 'few', 'fewer', 'fifth', 'first', 'five', 'followed', 'following', 'follows', 'for', 'forever', 'former', 'formerly', 'forth', 'forward', 'found', 'four', 'from', 'further', 'furthermore', 'g', 'get', 'gets', 'getting', 'given', 'gives', 'go', 'goes', 'going', 'gone', 'got', 'gotten', 'greetings', 'h', 'had', 'hadn\'t', 'half', 'happens', 'hardly', 'has', 'hasn\'t', 'have', 'haven\'t', 'having', 'he', 'he\'d', 'he\'ll', 'hello', 'help', 'hence', 'her', 'here', 'hereafter', 'hereby', 'herein', 'here\'s', 'hereupon', 'hers', 'herself', 'he\'s', 'hi', 'him', 'himself', 'his', 'hither', 'hopefully', 'how', 'howbeit', 'however', 'hundred', 'i', 'i\'d', 'ie', 'if', 'ignored', 'i\'ll', 'i\'m', 'immediate', 'in', 'inasmuch', 'inc', 'inc.', 'indeed', 'indicate', 'indicated', 'indicates', 'inner', 'inside', 'insofar', 'instead', 'into', 'inward', 'is', 'isn\'t', 'it', 'it\'d', 'it\'ll', 'its', 'it\'s', 'itself', 'i\'ve', 'j', 'just', 'k', 'keep', 'keeps', 'kept', 'know', 'known', 'knows', 'l', 'last', 'lately', 'later', 'latter', 'latterly', 'least', 'less', 'lest', 'let', 'let\'s', 'like', 'liked', 'likely', 'likewise', 'little', '\'ll', 'look', 'looking', 'looks', 'low', 'lower', 'ltd', 'm', 'made', 'mainly', 'make', 'makes', 'many', 'may', 'maybe', 'mayn\'t', 'me', 'mean', 'meantime', 'meanwhile', 'merely', 'might', 'mightn\'t', 'mine', 'minus', 'miss', 'more', 'moreover', 'most', 'mostly', 'mr', 'mrs', 'much', 'must', 'mustn\'t', 'my', 'myself', 'n', 'name', 'namely', 'nd', 'near', 'nearly', 'necessary', 'need', 'needn\'t', 'needs', 'neither', 'never', 'neverf', 'neverless', 'nevertheless', 'new', 'next', 'nine', 'ninety', 'no', 'nobody', 'non', 'none', 'nonetheless', 'noone', 'no-one', 'nor', 'normally', 'not', 'nothing', 'notwithstanding', 'novel', 'now', 'nowhere', 'o', 'obviously', 'of', 'off', 'often', 'oh', 'ok', 'okay', 'old', 'on', 'once', 'one', 'ones', 'one\'s', 'only', 'onto', 'opposite', 'or', 'other', 'others', 'otherwise', 'ought', 'oughtn\'t', 'our', 'ours', 'ourselves', 'out', 'outside', 'over', 'overall', 'own', 'particular', 'particularly', 'past', 'per', 'perhaps', 'placed', 'please', 'plus', 'possible', 'presumably', 'probably', 'provided', 'provides', 'q', 'que', 'quite', 'qv', 'r', 'rather', 'rd', 're', 'really', 'reasonably', 'recent', 'recently', 'regarding', 'regardless', 'regards', 'relatively', 'respectively', 'right', 'round', 's', 'said', 'same', 'saw', 'say', 'saying', 'says', 'second', 'secondly', 'see', 'seeing', 'seem', 'seemed', 'seeming', 'seems', 'seen', 'self', 'selves', 'sensible', 'sent', 'serious', 'seriously', 'seven', 'several', 'shall', 'shan\'t', 'she', 'she\'d', 'she\'ll', 'she\'s', 'should', 'shouldn\'t', 'since', 'six', 'so', 'some', 'somebody', 'someday', 'somehow', 'someone', 'something', 'sometime', 'sometimes', 'somewhat', 'somewhere', 'soon', 'sorry', 'specified', 'specify', 'specifying', 'still', 'sub', 'such', 'sup', 'sure', 't', 'take', 'taken', 'taking', 'tell', 'tends', 'th', 'than', 'thank', 'thanks', 'thanx', 'that', 'that\'ll', 'thats', 'that\'s', 'that\'ve', '\'ve', 'the', 'their', 'theirs', 'them', 'themselves', 'then', 'thence', 'there', 'thereafter', 'thereby', 'there\'d', 'therefore', 'therein', 'there\'ll', 'there\'re', 'theres', 'there\'s', 'thereupon', 'there\'ve', 'these', 'they', 'they\'d', 'they\'ll', 'they\'re', 'they\'ve', 'thing', 'things', 'think', 'third', 'thirty', 'this', 'thorough', 'thoroughly', 'those', 'though', 'three', 'through', 'throughout', 'thru', 'thus', 'till', 'to', 'together', 'too', 'took', 'toward', 'towards', 'tried', 'tries', 'truly', 'try', 'trying', 't\'s', 'twice', 'two', 'u', 'un', 'under', 'underneath', 'undoing', 'unfortunately', 'unless', 'unlike', 'unlikely', 'until', 'unto', 'up', 'upon', 'upwards', 'us', 'use', 'used', 'useful', 'uses', 'using', 'usually', 'v', 'value', 'various', 'versus', 'very', 'via', 'viz', 'vs', 'w', 'want', 'wants', 'was', 'wasn\'t', 'way', 'we', 'we\'d', 'welcome', 'well', 'we\'ll', 'went', 'were', 'we\'re', 'weren\'t', 'we\'ve', 'what', 'whatever', 'what\'ll', 'what\'s', 'what\'ve', 'when', 'whence', 'whenever', 'where', 'whereafter', 'whereas', 'whereby', 'wherein', 'where\'s', 'whereupon', 'wherever', 'whether', 'which', 'whichever', 'while', 'whilst', 'whither', 'who', 'who\'d', 'whoever', 'whole', 'who\'ll', 'whom', 'whomever', 'who\'s', 'whose', 'why', 'will', 'willing', 'wish', 'with', 'within', 'without', 'wonder', 'won\'t', 'would', 'wouldn\'t', 'x', 'y', 'yes', 'yet', 'you', 'you\'d', 'you\'ll', 'your', 'you\'re', 'you\'ve', 'yours', 'yourself', 'yourselves', 'you\'ve', 'z', 'zero', 'ada', 'adalah', 'agak', 'agar', 'akan', 'aku', 'amat', 'anda', 'apa', 'apabila', 'atau', 'bahwa', 'bagai', 'baru', 'beberapa', 'begitu', 'begini', 'bila', 'belum', 'betapa', 'banyak', 'boleh', 'cara', 'cuma', 'dan', 'dalam', 'dari', 'dapat', 'demikian', 'dengan', 'di', 'dia', 'hanya', 'harus', 'ialah', 'ini', 'ingin', 'itu', 'hanya', 'jika', 'juga', 'hendak', 'kali', 'kalau', 'kami', 'kan', 'karena', 'ke', 'kelak', 'kemudian', 'kenapa', 'kepada', 'kini', 'ku', 'lah', 'lain-lain', 'lagi', 'lalu', 'lama', 'lantas', 'maka', 'mana', 'masa', 'masih', 'mau', 'me', 'mereka', 'merupakan', 'meng', 'mengapa', 'mesti', 'mu', 'namun', 'nan', 'nun', 'nya', 'orang', 'pada', 'paling', 'pasti', 'para', 'pen', 'pengen', 'pernah', 'saat', 'saja', 'sana', 'sang', 'sangat', 'saya', 'sebagainya', 'sedang', 'sehingga', 'selain', 'selalu', 'seluruh', 'sekali', 'sekarang', 'sementara', 'semua', 'senantiasa', 'seorang', 'seseorang', 'seperti', 'serba', 'sering', 'serta', 'sesuatu', 'si', 'sini', 'situ', 'suatu', 'sudah', 'supaya', 'tahun', 'tanpa', 'telah', 'terus', 'untuk', 'yakni', 'yaitu', 'yang');
    return preg_replace('/\\b(' . implode('|', $commonWords) . ')\\b/', '', $input);
}
h2o::addFilter('remove_common_words');
<?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'));
 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');
 }
Exemple #27
0
 private function load()
 {
     if (isset(h2o::$extensions[$this->extension])) {
         return true;
     }
     foreach ($this->searchpath as $path) {
         $file = $path . 'ext' . DS . $this->extension . '.php';
         if (is_file($file)) {
             h2o::load($this->extension, $file);
             return $file;
         }
     }
     throw new H2o_Error("Extension: {$this->extension} cannot be loaded, please confirm it exist in extension path");
 }
Exemple #28
0
<?php

h2o::addTag('lorem');
class Lorem_Tag extends H2o_Node
{
    private $common = true;
    private $syntax = '/^(\\d+)?(?:\\s+(p|w))?(?:\\s?(random))?$/i';
    var $hint = "{% lorem [count] [format] [random]%}";
    function __construct($argstring, $parser, $position = 0)
    {
        if (!preg_match($this->syntax, trim($argstring), $match)) {
            throw new TemplateSyntaxError($this->hint);
        }
        @(list(, $count, $mode, $random) = $match);
        $this->count = $count ? $count : 1;
        $this->mode = $mode ? $mode : 'p';
        $this->common = !$random;
    }
    function render($context, $stream)
    {
        $output = '';
        switch ($this->mode) {
            case 'w':
                $output = lorem_words($this->count);
                break;
            case 'p':
                $output = "<p>" . join("</p>\n<p>", lorem_paragraphs($this->count, $this->common)) . '</p>';
                break;
        }
        $stream->write($output);
    }
Exemple #29
0
        if (abs($reldays) < 7) {
            if ($reldays > 0) {
                $reldays = floor($reldays);
                return 'in ' . $reldays . ' day' . ($reldays != 1 ? 's' : '');
            } else {
                $reldays = abs(floor($reldays));
                return $reldays . ' day' . ($reldays != 1 ? 's' : '') . ' ago';
            }
        }
        if (abs($reldays) < 182) {
            return date('l, F j', $time ? $time : time());
        } else {
            return date('l, F j, Y', $time ? $time : time());
        }
    }
    static function relative_datetime($time)
    {
        $date = self::relative_date($time);
        if ($date === 'today') {
            return self::relative_time($time);
        }
        return $date;
    }
}
/*  Ultizie php funciton as Filters */
h2o::addFilter(array('md5', 'sha1', 'numberformat' => 'number_format', 'wordwrap', 'trim', 'upper' => 'strtoupper', 'lower' => 'strtolower'));
/* Add filter collections */
h2o::addFilter(array('CoreFilters', 'StringFilters', 'NumberFilters', 'DatetimeFilters', 'HtmlFilters'));
/* Alias default to set_default */
h2o::addFilter('default', array('CoreFilters', 'set_default'));
Exemple #30
0
 public function should_be_able_to_register_a_filter_collection()
 {
     h2o::addFilter('SampleFilters');
     $result = h2o('{{ person | hello }}')->render(array('person' => 'peter'));
     expects($result)->should_be('says hello to peter');
 }