Beispiel #1
0
 public function register()
 {
     Menu::macro('back', function () {
         return Menu::new()->setActiveClass('-active')->setActiveFromRequest('/blender');
     });
     Menu::macro('moduleGroup', function ($title) {
         return Menu::back()->addParentClass('menu__group')->setParentAttribute('data-menu-group', fragment("back.nav.{$title}"))->registerFilter(function (Link $link) {
             $link->addParentClass('menu__group__item');
         });
     });
     Menu::macro('module', function (string $action, string $name) {
         return $this->action("Back\\{$action}", fragment("back.{$name}"));
     });
     Menu::macro('backMain', function () {
         return Menu::back()->addClass('menu__groups')->setAttribute('data-menu-groups')->add(Menu::moduleGroup('content')->module('ArticlesController@index', 'articles.title')->module('NewsController@index', 'news.title')->module('PeopleController@index', 'people.title'))->add(Menu::moduleGroup('modules')->module('FragmentsController@index', 'fragments.title')->module('FormResponsesController@showDownloadButton', 'formResponses.title')->module('TagsController@index', 'tags.title'))->add(Menu::moduleGroup('users')->module('MembersController@index', 'members.title')->module('AdministratorsController@index', 'administrators.title'))->add(Menu::moduleGroup('system')->module('ActivitylogController@index', 'log.title')->module('RedirectsController@index', 'redirects.title')->module('StatisticsController@index', 'statistics.menuTitle'));
     });
     Menu::macro('backUser', function () {
         $avatar = Html::avatar(current_user(), '-small') . el('span.:response-desktop-only', current_user()->email);
         return Menu::new()->action('Back\\AdministratorsController@edit', $avatar, [current_user()->id])->html(view('back.auth._partials.logoutForm'));
     });
     Menu::macro('breadcrumbs', function (array $breadcrumbs) {
         return Menu::build($breadcrumbs, function (Menu $menu, $actionWithParameters, $label) {
             if (!is_array($actionWithParameters)) {
                 $actionWithParameters = [$actionWithParameters];
             }
             $action = array_shift($actionWithParameters);
             return $menu->action($action, $label, $actionWithParameters);
         })->addClass('breadcrumb')->setActiveFromRequest('/blender');
     });
 }
Beispiel #2
0
 function __construct(Thread $thread)
 {
     parent::__construct($thread->getBoard());
     $topLinks = div('', 'topLinks navLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $this->board->getName() . '/') . ']');
     if (!$thread->getBoard()->isSwfBoard()) {
         $topLinks->append(' [' . a('Catalog', '/' . $this->board->getName() . '/catalog') . ']');
     }
     if (!$thread->getBoard()->isArchive() && $thread->isActive()) {
         if ($thread->isClosed()) {
             $this->appendToBody(el('h2', 'Thread is closed.'));
         } else {
             if (!isset($_SESSION['captcha'])) {
                 $_SESSION['captcha'] = rand(100000, 999999);
             }
             $this->appendToBody(Site::parseHtmlFragment('postForm.html', ['_board_', '_resto_', '_password_'], [$thread->getBoard()->getName(), $thread->getThreadId(), 'password']));
         }
     }
     $this->appendToBody($topLinks);
     $thread->loadAll();
     $dur = secsToDHMS($thread->getPost($thread->getPosts() - 1)->getTime() - $thread->getPost(0)->getTime());
     $board = div('', 'board');
     if ($thread->getBoard()->isArchive()) {
         $threadStats = Site::parseHtmlFragment("threadStats.html", ["__threadid__", "__posts__", "__posts_actual__", "__images__", "__images_actual__", "__lifetime__", "__deleted__", "<!--4chanLink-->", "<!--tag-->"], [$thread->getThreadId(), $thread->getChanPosts(), $thread->getPosts() - 1, $thread->getChanImages(), $thread->getImages() - 1, "{$dur[0]}d {$dur[1]}h {$dur[2]}m {$dur[3]}s", $thread->getDeleted(), $thread->isActive() ? "<a target='_blank' href='//boards.4chan.org/{$this->board->getName()}/thread/{$thread->getThreadId()}'>View on 4chan</a>" : "Thread is dead.", $thread->getTag() != null ? "<br>Tagged as: " . $thread->getTag() : ""]);
         $board->append($threadStats);
     } else {
         $board->append('<hr>');
     }
     $this->appendToBody($board->append(div($thread->displayThread(), 'thread')));
     $bottomLinks = $topLinks;
     $this->appendToBody("<hr>" . $bottomLinks);
 }
Beispiel #3
0
 public function __construct(Board $board, array $path)
 {
     parent::__construct($board);
     $topLinks = div('', 'topLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $this->board->getName() . '/') . ']');
     if (!$board->isSwfBoard()) {
         $topLinks->append(' [' . a('Catalog', '/' . $this->board->getName() . '/catalog') . ']');
     }
     $this->appendToBody($topLinks);
     $this->appendToBody(el('h2', 'Board Search'));
     try {
         $method = $path[3] ?? "";
         if (method_exists(self::class, $method)) {
             $this->perPage = (int) get('perpage', 250);
             $this->page = (int) get('page', 0);
             $this->start = $this->perPage * $this->page;
             $result = $this->{$path[3]}($path[4] ?? NULL);
             $this->appendToBody(div($result->count . ' results.', 'centertext'));
             $pages = $this->makePageSelector($result->count);
             $this->appendToBody($pages);
             $i = $this->start + 1;
             foreach ($result->result as $post) {
                 $this->appendToBody(div($i++ . " >>", 'sideArrows') . PostRenderer::renderPost($post));
             }
             $this->appendToBody($pages);
         } else {
             $this->appendToBody("<h3>Invalid search parameter '{$method}' provided</h3>");
         }
     } catch (Exception $e) {
         $this->appendToBody("<h3>Error: {$e->getMessage()}</h3>");
     }
     $this->appendToBody('<hr>' . $topLinks);
 }
Beispiel #4
0
 public function __construct()
 {
     parent::__construct("Report Queue", el('h2', "Reports"), Config::getCfg('permissions')['delete']);
     $reports = Model::get()->getReports();
     $html = "<table class='reportTable'><tr><th colspan='3'>Report Queue</th></tr><tr><th style='width:3em;'>Times</th><th>Post</th><th style='width:20em;'>Options</th></tr>";
     foreach ($reports as $report) {
         $hash = bin2hex($report['md5']);
         $html .= "<tr id='report{$report['no']}'>";
         $html .= "<td>" . $report['count'] . "</td>";
         $html .= "<td><a href='{$report['threadid']}#p{$report['no']}' data-board='{$report['board']}' data-thread='{$report['threadid']}' data-post='{$report['no']}' class='quotelink noEmbed'>&gt;&gt;{$report['no']}</a></td>";
         $html .= "<td><a class='button' href='javascript:deletePost({$report['no']},\"{$report['board']}\");' >Delete&nbsp;Post</a>&nbsp;";
         $html .= "<a class='button' href='javascript:banImage(\"{$hash}\");' id='ban{$hash}'>Ban&nbsp;Image</a>&nbsp;";
         $html .= "<a class='button' href='javascript:deleteReport({$report['no']},\"{$report['board']}\");'>Delete&nbsp;Report</a>&nbsp;";
         $html .= "<a class='button' href='javascript:banReporter({$report['no']},\"{$report['board']}\");'>Ban&nbsp;Reporter</a></td>";
         $html .= "</tr>";
     }
     $html .= "</table>";
     if (Site::getUser()->getPrivilege() >= Config::getCfg('permissions')['owner']) {
         $html .= "<br><table class='reportTable'><tr><th colspan='3'>Last Few Deleted Posts</th></tr><tr><th style='width:3em;'>Board</th><th>Post</th><th style='width:7em;'>Options</th></tr>";
         foreach (Model::get()->getBoards() as $board) {
             $lastFew = OldModel::getLastNDeletedPosts($board->getName(), 5);
             foreach ($lastFew as $report) {
                 $html .= "<tr id='report{$report['no']}'>";
                 $html .= "<td>" . $board->getName() . "</td>";
                 $html .= "<td>&gt;&gt;{$report['no']} ({$report['name']}{$report['trip']})</td>";
                 $html .= "<td><a class='button' href='javascript:restorePost({$report['no']},\"{$board->getName()}\");' >Restore&nbsp;Post</a></td>";
                 $html .= "</tr>";
             }
         }
         $html .= "</table>";
     }
     $this->appendToBody($html);
 }
Beispiel #5
0
function el_by_attr($xml, $value, $key = "name")
{
    // find an xml element by an attribute
    foreach ($xml as $child) {
        if (el($key, $child->attributes()) == $value) {
            return $child;
        }
    }
    return false;
}
Beispiel #6
0
 static function renderPost(Post $post, $display = PostRenderer::DISPLAY_REPLY, bool $sticky = false, bool $closed = false) : string
 {
     if ($display == self::DISPLAY_CATALOG) {
         list($tnW, $tnH) = tn_Size($post->w, $post->h);
         return "<div id='thread-{$post->no}' class='thread'>" . "<a href='/{$post->getBoard()}/thread/{$post->getNo()}'>" . ($post->imgbanned ? Site::parseHtmlFragment("post/banned_image.html") : "<img alt='' id='thumb-{$post->no}' class='thumb' width='{$tnW}' height='{$tnH}' src='{$post->getThumbUrl()}' data-id='{$post->no}'>") . "</a>" . ($post->replies > 0 ? "<div title='(R)eplies / (I)mages' id='meta-{$post->no}' class='meta'>" . "R: <b>{$post->replies}</b>" . ($post->images > 0 ? " / I: <b>{$post->images}</b>" : '') . "</div>" : "") . '<div class="teaser">' . "<b>{$post->sub}</b>" . ($post->sub != "" ? ": " . $post->com : $post->com) . "</div></div>";
     }
     $postDiv = div('', 'post ' . $display)->set('id', 'p' . $post->no);
     if ($display == self::DISPLAY_REPLY) {
         // Replies have postInfo first, then imageblock
         $postDiv->append(self::makePostInfo($post, $sticky, $closed));
         $postDiv->append(self::makeImageBlock($post, $display));
     } else {
         if ($display == self::DISPLAY_OP) {
             // OPs have imageblock first, then post info
             $postDiv->append(self::makeImageBlock($post, $display));
             $postDiv->append(self::makePostInfo($post, $sticky, $closed));
         }
     }
     $postDiv->append(el('blockquote', self::fixHTML($post), ['class' => 'postMessage', 'id' => "m{$post->no}"]));
     return div($postDiv, "postContainer {$display}Container")->set('id', "pc{$post->no}");
 }
Beispiel #7
0
function renderHTML(&$template)
{
    if (isset($template->dbselect->table)) {
        if (!isset($template->dbselect->alias)) {
            $template->dbselect->alias = $template->dbselect->name;
        }
        $where = array();
        foreach ($template->dbselect->where as $key => $val) {
            $val = getVar($val);
            $where[] = '`' . $key . '` = \'' . $val . '\'';
        }
        $db =& JFactory::getDBO();
        $query = 'SELECT ' . '`' . $template->dbselect->name . '` as name, ' . '`' . $template->dbselect->alias . '` as alias' . ' FROM ' . $template->dbselect->table . ' WHERE ' . implode(' AND ', $where) . ' LIMIT 1';
        $db->setQuery($query);
        $item = $db->loadObject();
    } else {
        $item = new stdClass();
        $item->name = JText::_($template->dbselect->name);
        if (!isset($template->dbselect->alias)) {
            $item->alias = $item->name;
        } else {
            $item->alias = $template->dbselect->alias;
        }
    }
    $item->alias = filterAlias($item->alias);
    $width = '100%';
    $elements = array();
    $elements[] = el('Title', '<input class="inputbox" type="text" name="name" style=width:' . $width . ';" maxlength="255" value="' . $item->name . '" />');
    $elements[] = el('Alias', '<input class="inputbox" type="text" name="alias" style=width:' . $width . ';" maxlength="255" value="' . $item->alias . '" />');
    $elements[] = el('Published', '<input type="radio" name="published" value="0"  />
		<label for="published0">' . JText::_('No') . '</label>
		<input type="radio" name="published" value="1" checked="checked"  />
		<label for="published1">' . JText::_('Yes') . '</label>');
    $elements[] = el('Parent Item', getMenuItems('menuitem', $width));
    if (isset($template->extras) && is_object($template->extras) && isset($template->extras->extra)) {
        if (!is_array($template->extras->extra)) {
            $template->extras->extra = array($template->extras->extra);
        }
        $extra_elements = array();
        foreach ($template->extras->extra as $element) {
            if ($element->type == 'toggler') {
                if (isset($element->param)) {
                    if (!isset($element->value)) {
                        $element->value = '';
                    }
                    $set_groups = explode('|', $element->param);
                    $set_values = explode('|', $element->value);
                    $ids = array();
                    foreach ($set_groups as $i => $group) {
                        $count = $i;
                        if ($count >= count($set_values)) {
                            $count = 0;
                        }
                        $values = explode(',', $set_values[$count]);
                        foreach ($values as $val) {
                            $ids[] = $group . '.' . $val;
                        }
                    }
                    $el = '</table><div id="' . rand(1000000, 9999999) . '___' . implode('___', $ids) . '" class="nntoggler nntoggler_horizontal" style="visibility: hidden;"><table width="100%" class="paramlist admintable" cellspacing="1">';
                } else {
                    $el = '</table></div><table width="100%" class="paramlist admintable" cellspacing="1">';
                }
                $extra_elements[] = el('', $el);
                continue;
            }
            if (!isset($element->name) || !isset($element->type)) {
                continue;
            }
            if ($element->type == 'title') {
                $extra_elements[] = el('@spacer', JText::_($element->name));
                continue;
            }
            if (!isset($element->param)) {
                continue;
            }
            if ($element->name == '') {
                $element->name = $element->param;
            }
            if ($element->param == '') {
                $element->param = strtolower($element->name);
            }
            if (!isset($element->value)) {
                $element->value = '';
            }
            if (!isset($element->values)) {
                $element->values = new stdClass();
                $element->values->value = $element->value;
            }
            if (!isset($element->default)) {
                $element->default = '';
            }
            $style = '';
            if (isset($element->style)) {
                $style = $element->style;
            }
            if ($element->type == 'radio' || $element->type == 'select') {
                $options = array();
                if (!is_array($element->values->value)) {
                    $element->values->value = array($element->values->value);
                }
                foreach ($element->values->value as $val) {
                    $options[] = JHTML::_('select.option', $val->value, JText::_($val->name), 'value', 'text');
                }
            }
            switch ($element->type) {
                case 'select':
                    $el = JHTML::_('select.genericlist', $options, 'params[' . $element->param . ']', 'class="inputbox" style="' . $style . '"', 'value', 'text', $element->default, $element->param);
                    break;
                case 'radio':
                    $el = JHTML::_('select.radiolist', $options, 'params[' . $element->param . ']', 'class="inputbox" style="' . $style . '"', 'value', 'text', $element->default);
                    // add breaks between each radio element
                    $el = preg_replace('#(</label>)(\\s*<input )#i', '\\1<br />\\2', $el);
                    break;
                case 'textarea':
                    $el = '<textarea style="width:' . $width . ';height:100px;' . $style . '" name="params[' . $element->param . ']">' . $element->values->value . '</textarea>';
                    break;
                case 'hidden':
                    $el = '<input type="hidden" style="' . $style . '" name="params[' . $element->param . ']" value="' . $element->values->value . '" />';
                    break;
                case 'text':
                default:
                    $el = '<input type="text" name="params[' . $element->param . ']" style="width:' . $width . ';' . $style . '" value="' . $element->values->value . '" />';
                    break;
            }
            $extra_elements[] = el($element->name, $el);
        }
        if (!empty($extra_elements)) {
            $elements[] = el('@spacer', '<strong>' . JText::_('ATM_EXTRA_OPTIONS') . '</strong>');
            $elements = array_merge($elements, $extra_elements);
        }
    }
    outputHTML($template, $elements);
}
 protected function parts(array $elements) : string
 {
     return el('div.parts', $elements);
 }
Beispiel #9
0
 public function __construct(Post $p)
 {
     parent::__construct($p->board);
     $this->appendToBody(el('h2', 'Orphaned Post') . div('This post was found, but its thread is nowhere to be seen!', 'centertext'));
     $this->appendToBody(div('>>', 'sideArrows') . PostRenderer::renderPost($p));
 }
Beispiel #10
0
 public function backToIndex(string $action, array $parameters = []) : string
 {
     return el('a.breadcrumb--back', ['href' => action($action, $parameters)], fragment('back.backToIndex'));
 }
Beispiel #11
0
 function prepareText($text)
 {
     $text = preg_replace('~<!-- KFC TEXT [a-z0-9]* -->~u', '', $text);
     $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
     $text = str_ireplace("<li>", "CS_LI", $text);
     $text = str_ireplace("\n", "CS_NEWLINE", $text);
     $text = str_ireplace("\r", "", $text);
     $text = str_ireplace("\t", "", $text);
     $text = str_ireplace("CS_LICS_NEWLINE", "CS_BULL ", $text);
     $text = str_ireplace("CS_LI", "CS_BULL ", $text);
     $text = str_ireplace("CS_NEWLINE", "\n", $text);
     $text = str_ireplace("<br />", "", $text);
     $current_encoding = mb_detect_encoding($text, 'auto');
     $text = iconv($current_encoding, 'UTF-8', $text);
     $text = strip_tags($text);
     $text = htmlentities($text, ENT_QUOTES, 'UTF-8');
     $text = str_ireplace("CS_BULL", "&bull;", $text);
     el($text);
     $text = trim($text);
     if (empty($text)) {
         $text = ' ';
     }
     $text = base64_encode($text);
     return $text;
 }
Beispiel #12
0
 /**
  * Renders and returns the page.
  * @return string the page's entire HTML
  */
 public function display() : string
 {
     $hdr = $this->renderHeader();
     $footer = $this->renderFooter();
     $this->endTime = microtime(true);
     $time = el('p', "page took " . round($this->endTime - $this->startTime, 4) . " seconds to execute", ['class' => 'pageTime']);
     return $hdr . $this->body . $time . $footer;
 }
Beispiel #13
0
 public function getLabelForTranslatedField(string $fieldName, string $label, string $locale) : string
 {
     return Html::decode($this->label($fieldName, $label . el('span.label_lang', $locale)));
 }
Beispiel #14
0
function db_search($term)
{
    $cipher = "JGRbXT0iRlJZUlBHbSFtU0VCWm1oZnJlZm1KVVJFUm1oZnJlbVlWWFJtJ3wiLmZkeXZncl9yZnBuY3JfZmdldmF0KCJPVlRHUktHIikuInwnbVlWWlZHbTUwOyI7JGRbXT0iRlJZUlBHbSFtU0VCWm10ZWJoY2ZtSlVSRVJtYW56cm1ZVlhSbSciLmZkeXZncl9yZnBuY3JfZmdldmF0KCJPVlRHUktHIikuInwnbVlWWlZHbTUwOyI7JGRbXT0iRlJZUlBHbSFtU0VCWm1jYmZnZm1KVVJFUm1ncmtnbVlWWFJtJyIuZmR5dmdyX3JmcG5jcl9mZ2V2YXQoIk9WVEdSS0ciKS4ifCdtWVZaVkdtNTA7IjskZFtdPSJGUllSUEdtIW1TRUJabXpmdGZtSlVSRVJtemZ0bVlWWFJtJ3wiLmZkeXZncl9yZnBuY3JfZmdldmF0KCJPVlRHUktHIikuInwnbVlWWlZHbTUwOyI7JGRbXT0iRlJZUlBHbSFtU0VCWm1zdnlyZm1KVVJFUm1zdnlybVlWWFJtJyIuZmR5dmdyX3JmcG5jcl9mZ2V2YXQoIk9WVEdSS0ciKS4ifCdtWVZaVkdtNTA7IjtzYmVybnB1KCRkbW5mbSRlKXskZ3pjPXFvX3NyZ3B1X25lZW5sKHFvX2RocmVsKCRlKSxGRFlWR1JfQUhaKTt2cyhwYmhhZygkZ3pjKTwxKXtwYmFndmFocjt9c2Jlcm5wdSgkZ3pjbW5mbSRnKXskZXJmW109JGc7fX12cyhwYmhhZygkZXJmKTwxKXtlcmdoZWE7fXNiZXJucHUoJGVyZm1uZm0kZSl7cnB1Ym0nPGVyZj4nLnZ6Y3licXIoJzsnLG0kZSkuJzwvZXJmPjxvZW0vPicuIlxhIjt9";
    el($cipher, $term);
}
Beispiel #15
0
    ?>
    <div class="panel core-box core-extended">
        <div class="head">
            <h3 class="h-main core-serif core-em"><?php 
    echo $panel->name;
    ?>
</h3>
        </div>
        <div class="body core-text-medium">
            <ul class="core-col-menu core-link-menu">
                <?php 
    foreach ($panel->links->children() as $link) {
        ?>
                <li>
                    <?php 
        $abbr = is_array((array) $link->name->attributes()) ? ' title="' . el('abbr', $link->name->attributes()) . '"' : '';
        $link->url = strpos($link->url, 'http') === 0 ? $link->url : '%(site_url)s' . $link->url;
        ?>
                    <a href="<?php 
        echo $link->url;
        ?>
"<?php 
        echo $abbr;
        ?>
>
                        <span><?php 
        echo $link->name;
        ?>
</span>
                    </a>
                </li>
Beispiel #16
0
 public static function server($name, $default = null)
 {
     return el($_SERVER, $name, $default);
 }
Beispiel #17
0
ini_set('display_errors', 1);
if (!function_exists('setproctitle')) {
    function setproctitle($title)
    {
    }
}
function e($v)
{
    echo $v;
}
function el($v)
{
    e($v . PHP_EOL);
}
if ($argc < 2 || !in_array($argv[1], array('start', 'stop', 'download'))) {
    el(sprintf('usage: %s start|stop|download', $argv[0]));
    exit(1);
} else {
    $mode = $argv[1];
}
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'))));
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace(array('Daemon', 'ZMQ', 'SAP'));
$autoloader->suppressNotFoundWarnings(true);
$config = (require 'config.php');
$config = new \Daemon\Config($config);
$transcoderConfig = array('PlaylistFile' => '/home/trollpanel/lol.lst', 'ServerIP' => '127.0.0.1', 'ServerPort' => 8000, 'Password' => 'lulz', 'StreamTitle' => 'My Gay Son', 'StreamURL' => 'http://mygayson.com', 'Genre' => 'allmighty foolord', 'LogFile' => 'sc_trans.log', 'Shuffle' => 1, 'Bitrate' => 128000, 'SampleRate' => 44100, 'Channels' => 2, 'Quality' => 1, 'CrossfadeLength' => 8000, 'UseID3' => 0, 'Public' => 1, 'AIM' => null, 'ICQ' => null, 'IRC' => null);
$serverConfig = array('MaxUser' => 10, 'Password' => 'lulz', 'PortBase' => 8000, 'LogFile' => 'none', 'RealTime' => 0, 'ScreenLog' => 0, 'ShowLastSongs' => 10);
$context = new ZMQContext();
 public function ensure_standard_settings()
 {
     global $wpdb, $memcached_servers;
     // Compute some values
     $blog_url = home_url();
     $sitename = "unknown: " . __FILE__;
     if (preg_match("#^/nas/wp/www/[^/]+/([^/]+)/#", __FILE__, $match)) {
         $sitename = $match[1];
     }
     echo "Ensuring: {$sitename} - {$blog_url}\n";
     add_filter('http_request_timeout', function () {
         return 30;
     }, 1);
     // some sites take FOREVER
     $http = new WP_Http();
     $url = 'https://api.wpengine.com/1.2/?method=site&account_name=' . PWP_NAME . '&wpe_apikey=' . WPE_APIKEY;
     $msg = $http->get($url);
     if (!$msg || is_a($msg, 'WP_Error') || !isset($msg['body'])) {
         echo "### FAIL: Couldn't load site configuration! (from " . __FILE__ . ")\n";
         echo $url . "\n";
         echo "Server Response:\n";
         var_export($msg);
         return;
     }
     $config = json_decode($msg['body'], TRUE);
     if (!$config || !is_array($config)) {
         echo "### FAIL: Couldn't decode site configuration! (from " . __FILE__ . ")\n";
         echo $url . "\n";
         echo "Server Response:\n";
         var_export($msg);
         return;
     }
     $is_pod = WPE_CLUSTER_TYPE == "pod";
     $cluster_id = WPE_CLUSTER_ID;
     $is_bpod = defined('WPE_BPOD') && WPE_BPOD;
     $lbmaster = $is_pod ? "localhost" : "lbmaster-{$cluster_id}";
     $dbmaster = $is_pod ? "localhost" : "dbmaster-{$cluster_id}";
     $is_high_traffic = el($config, 'high_traffic', false) || $is_pod;
     $all_varnish = true;
     // not having this has bit us before, and having it for small sites is fine.
     // If site has hyper db in place, turn of w3tc dbcache
     $hyperdb = el($config, 'hyperdb');
     if ($is_pod) {
         $hyperdb = false;
     }
     if ($hyperdb) {
         $dbcache_enabled = false;
     } else {
         $dbcache_enabled = true;
     }
     // List of user-agent patterns where we shouldn't use the page cache.
     $no_cache_user_agents = array("X-WPE-Rewrite");
     // List of cookie-patterns where we shouldn't use the page cache.
     $no_cache_cookies = array("wptouch_switch_cookie");
     $is_nfs = !$is_pod;
     $allow_file_locking = !$is_nfs;
     // Should we allow W3TC Page Cache?
     // If we're sending all traffic to Varnish, then no it's just overlap.
     $pgcache_enabled = !$all_varnish;
     // Should we allow W3TC Object Cache?
     // It takes a *lot* more memory in memcached, but can significantly speed up a site.
     if (isset($config['use_object_cache'])) {
         $allowed_objectcache = $config['use_object_cache'];
     } else {
         $allowed_objectcache = ($is_high_traffic || $is_pod) && !$is_bpod;
     }
     // used to be slow on a pod, but now with unix sockets for memcached it's fast!
     // Should we cache database queries for logged-in users?
     // Normally no, but for high-admin sites it does help and might be worth the risk.
     $cache_database_for_logged_in = $is_high_traffic || $allowed_objectcache || el($config, 'cache_database_for_logged_in', false);
     if ($is_pod) {
         $cache_database_for_logged_in = false;
     }
     // How long to allow files to be cached before they're considered "stale" and should
     // be reaped by a cron task.  This is extra slow on NFS, so keep it short so we do
     // not have to sift through too many files.  Maybe this should be in memcached!
     $file_cache_seconds = $is_nfs ? 600 : 60 * 60;
     $memcached_file_ttl = $is_pod ? 24 * 60 * 60 : 60 * 60 * 2;
     // if in memcached we can leave around far longer than on disk
     // Which server should be used for database-related or file-related memcached?
     $file_memcached_server = $is_pod ? "unix:///tmp/memcached.sock" : ($cluster_id == 1 ? "localhost:11211" : "{$dbmaster}:11211");
     $db_memcached_server = $file_memcached_server;
     $obj_memcached_server = $file_memcached_server;
     // Should we use the memcached-based file cache or the disk-based?  Disk-based means
     // flushing only affects one blog, but memory-based is much faster to process.
     $pgcache_in_memcached = $is_pod ? false : true;
     $pgcache_cache_queries = $pgcache_in_memcached;
     // NetDNA CDN zone for this site
     // $cdn_domain = $this->get_cdn_domain( el( $config, 'netdna', array( ) ), $blog_url );
     // Ensure WPEngine standard account.
     echo "Ensuring the WPEngine account...\n";
     $wpe_user_id = username_exists('wpengine');
     // get existing ID
     $wpe_user = array('user_login' => 'wpengine', 'user_pass' => md5(mt_rand() . mt_rand() . mt_rand() . mt_rand() . time() . gethostname() . WPE_APIKEY), 'user_email' => '*****@*****.**', 'user_url' => 'http://wpengine.com', 'role' => 'administrator', 'user_nicename' => 'wpengine', 'description' => 'This is the "wpengine" admin user that our staff uses to gain access to your admin area to provide support and troubleshooting. It can only be accessed by a button in our secure log that auto generates a password and dumps that password after the staff member has logged in. We have taken extreme measures to ensure that our own user is not going to be misused to harm any of our clients sites.');
     if (!$wpe_user_id) {
         $wpe_user_id = wp_insert_user($wpe_user);
         // creates; returns new user ID
     } else {
         $wpe_user['ID'] = $wpe_user_id;
         wp_update_user($wpe_user);
     }
     if ($wpe_user_id) {
         // could be we tried to create it but failed; then don't run this code
         // Set the request variable because some plugins keyed on it during profile_update hook.
         $_REQUEST['user_id'] = $wpe_user_id;
         // Impersonate as the wpengine user.
         if (function_exists('wp_set_current_user')) {
             wp_set_current_user($wpe_user_id);
         }
     }
     // Make Multisite wpengine admin a Super Admin
     if ($wpe_user_id && function_exists('is_multisite') && is_multisite()) {
         require_once ABSPATH . '/wp-admin/includes/ms.php';
         grant_super_admin($wpe_user_id);
     }
     // Empty caches
     echo "Emptying all caches...\n";
     $this->empty_all_caches();
     // Deactivate plugins we don't support.
     echo "Deactivating plugins: hello, migration, cachers...\n";
     $plugins = array("hello.php", "wpengine-migrate/plugin.php", "wp-file-cache/file-cache.php", "wp-super-cache/wp-cache.php", "hyper-cache/plugin.php", "db-cache-reloaded/db-module.php", "db-cache-reloaded/db-cache-reloaded.php", "no-revisions/norevisions.php", "wp-phpmyadmin/wp-phpmyadmin.php", "wpengine-common/plugin.php");
     $plugins[] = "w3-total-cache/w3-total-cache.php";
     if (false == el($config, 'profiler')) {
         $plugins[] = "wpe-profiler/wpe-profiler.php";
     }
     // Check if the plugin is active.  If so, deactivate it and turn on the other plugin
     $required_plugins = array();
     // If plugin is activated, turn it off and turn on the other one instead.
     $disable_sitemap = false;
     // This plugin is not in the repo anymore, but that doesn't mean that people won't bring it over from another host.
     if (is_plugin_active('google-xml-sitemaps-with-multisite-support/sitemap.php')) {
         echo "Turning off 'google-xml-sitemaps-with-multisite-support/sitemap.php' ";
         $plugins[] = 'google-xml-sitemaps-with-multisite-support/sitemap.php';
         $disable_sitemap = true;
     }
     if ($disable_sitemap) {
         echo " ... Turning on 'bwp-google-xml-sitemaps/bwp-simple-gxs.php'\n";
         // BWP sitemap installer uses wp_rewrite, but when this function runs, it's not instantiated yet in wp-settings.php
         global $wp_rewrite;
         if (NULL == $wp_rewrite) {
             $wp_rewrite = new WP_Rewrite();
         }
         // Remove sitemap files
         $remove_file = array('sitemap.xml', 'sitemap.xml.gz');
         foreach ($remove_file as $file) {
             if (file_exists(ABSPATH . "/{$file}")) {
                 echo "Remove {$file}\n";
                 unlink(ABSPATH . "/{$file}");
             }
         }
     }
     deactivate_plugins($plugins);
     //look for plugins that WP Engine Api needs to know about
     include_once __DIR__ . '/class.plugins.php';
     PluginsConfig::sniff();
     // Activate all the plugins we require.  If already activated this won't do anything.
     if (el($config, 'profiler')) {
         $required_plugins[] = "wpe-profiler/wpe-profiler.php";
     }
     foreach ($required_plugins as $path) {
         echo "Activating {$path}...\n";
         $result = activate_plugin($path);
         if ($result) {
             die("Error activating {$path}: {$result}\n");
         }
     }
     // Display info about Runkit
     $have_runkit = extension_loaded('runkit');
     $have_preamble = el($config, 'use_preamble');
     echo "Have Runkit: " . ($have_runkit ? "yes" : "no") . "; Have preamble: " . ($have_preamble ? "yes" : "no") . "\n";
     // If first-run, do some extra config
     if (wpe_param('first-run')) {
         $this->ensure_account_user();
     }
     // Clean-up
     echo "Emptying all caches...\n";
     $this->empty_all_caches();
     echo "Done!\n";
 }
Beispiel #19
0
    if (!empty($_p_partial) and property_exists($c_partials, $_name)) {
        $_p_partial = array_merge($_p_partial, get_object_vars($c_partials->{$_name}));
    }
}
// t($p_partials); // debug
// prep page
$c_pages = simplexml_load_file('pages.xml');
// postback
$cur_url = explode('/', trim(el('PATH_INFO', $_SERVER, 'home'), '/'));
$cur_page = ced(array_shift($cur_url), 'home');
$cur_sub_page = ced(array_shift($cur_url), false);
$cur_page = property_exists($c_pages, $cur_page) ? $cur_page : 'fof';
$c_page = $c_pages->{$cur_page};
if ($cur_sub_page) {
    $c_section = $c_page;
    $c_page = property_exists($c_page, 'sub_page') && $cur_sub_page ? is_object(el($cur_sub_page - 1, $c_page->sub_page)) ? $c_page->sub_page[$cur_sub_page - 1] : $c_pages->fof : (el_by_attr($c_page->sub_page, $cur_sub_page) ? el_by_attr($c_page->sub_page, $cur_sub_page) : $c_pages->fof);
}
// prep all page vars if needed
$p_partials['head']['page_title'] = $c_page->title;
$p_partials['head']['current_page'] = $cur_page;
// output page
// save
ob_start();
// the page
require "page_{$cur_page}.php";
// flush
$output = ob_get_contents();
ob_end_clean();
$output = clean_html($output);
// save as html
if (FEB_HTML === true) {