Пример #1
0
 /**
  * ==========================================================
  *  DATE AGO CALCULATOR
  * ==========================================================
  *
  * -- CODE: -------------------------------------------------
  *
  *    $input = '2014-05-30 09:22:42';
  *
  *    var_dump(Date::ago($input));
  *
  * ----------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter | Type    | Description
  *  --------- | ------- | -----------------------------------
  *  $input    | mixed   | The date input
  *  $output   | string  | Optional to output single data
  *  $compact  | boolean | Remove empty leading offset(s)?
  *  --------- | ------- | -----------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function ago($input, $output = null, $compact = true)
 {
     $speak = Config::speak();
     $date = new DateTime();
     $date->setTimestamp((int) self::format($input, 'U'));
     $interval = $date->diff(new DateTime('now'));
     $time = $interval->format('%y.%m.%d.%h.%i.%s');
     $time = explode('.', $time);
     $time = Converter::strEval($time);
     $data = array('year' => $time[0], 'month' => $time[1], 'day' => $time[2], 'hour' => $time[3], 'minute' => $time[4], 'second' => $time[5]);
     if ($compact) {
         foreach ($data as $k => $v) {
             if ($v === 0) {
                 unset($data[$k]);
             } else {
                 break;
             }
         }
     }
     $results = array();
     foreach ($data as $k => $v) {
         $text = array($speak->{$k}, $speak->{$k . 's'});
         $results[$k] = $v . ' ' . ($v === 1 ? $text[0] : $text[1]);
     }
     unset($data);
     return !is_null($output) ? $results[$output] : $results;
 }
Пример #2
0
 /**
  * ==========================================================
  *  DATE AGO CALCULATOR
  * ==========================================================
  *
  * -- CODE: -------------------------------------------------
  *
  *    $input = '2014-05-30 09:22:42';
  *
  *    var_dump(Date::ago($input));
  *
  * ----------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter | Type    | Description
  *  --------- | ------- | -----------------------------------
  *  $input    | mixed   | The date input
  *  $output   | string  | Optional to output single data
  *  $compact  | boolean | Remove empty leading offset(s)?
  *  --------- | ------- | -----------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function ago($input, $output = null, $compact = true)
 {
     $speak = Config::speak();
     $date = new DateTime();
     $date->setTimestamp((int) self::format($input, 'U'));
     $interval = $date->diff(new DateTime('now'));
     $time = $interval->format('%y.%m.%d.%h.%i.%s');
     $time = explode('.', $time);
     $time = Converter::strEval($time);
     $data = array($speak->year . '|' . $speak->years => $time[0], $speak->month . '|' . $speak->months => $time[1], $speak->day . '|' . $speak->days => $time[2], $speak->hour . '|' . $speak->hours => $time[3], $speak->minute . '|' . $speak->minutes => $time[4], $speak->second . '|' . $speak->seconds => $time[5]);
     if ($compact) {
         foreach ($data as $k => $v) {
             if ($offset === 0) {
                 unset($data[$k]);
             } else {
                 break;
             }
         }
     }
     $results = array();
     foreach ($data as $k => $v) {
         $text = explode('|', $k);
         $results[strtolower($text[0])] = $v . ' ' . ($v === 1 ? $text[0] : $text[1]);
     }
     unset($data);
     return !is_null($output) ? $results[$output] : $results;
 }
Пример #3
0
 public static function info($folder = null, $array = false)
 {
     $config = Config::get();
     $speak = Config::speak();
     // Check whether the localized "about" file is available
     if (!($info = File::exist(PLUGIN . DS . $folder . DS . 'about.' . $config->language . '.txt'))) {
         $info = PLUGIN . DS . $folder . DS . 'about.txt';
     }
     $default = 'Title' . S . ' ' . ucwords(Text::parse($folder, '->text')) . "\n" . 'Author' . S . ' ' . $speak->anon . "\n" . 'URL' . S . ' #' . "\n" . 'Version' . S . ' 0.0.0' . "\n" . "\n" . SEPARATOR . "\n" . "\n" . Config::speak('notify_not_available', $speak->description);
     $info = Text::toPage(File::open($info)->read($default), 'content', 'plugin:');
     return $array ? $info : Mecha::O($info);
 }
Пример #4
0
                $menus[$speak->error] = array('icon' => 'exclamation-triangle', 'url' => $config->manager->slug . '/error', 'count' => $total, 'stack' => 9.130000000000001);
            }
        }
        if ($config->page_type !== '404' && $config->is->post) {
            $type = $config->page_type;
            $id = $config->{$type}->id;
            $text = Config::speak($type);
            $text_repair = Config::speak('manager._this_', array($speak->edit, $text));
            $text_kill = Config::speak('manager._this_', array($speak->delete, $text));
            $bars[$text] = array('icon' => 'plus', 'url' => $config->manager->slug . '/' . $type . '/ignite', 'description' => Config::speak('manager.title_new_', $text), 'stack' => 9.029999999999999);
            $bars[$speak->edit] = array('icon' => 'pencil', 'url' => $config->manager->slug . '/' . $type . '/repair/id:' . $id, 'description' => $text_repair, 'stack' => 9.039999999999999);
            $bars[$speak->delete] = array('icon' => 'times', 'url' => $config->manager->slug . '/' . $type . '/kill/id:' . $id, 'description' => $text_kill, 'stack' => 9.050000000000001);
        } else {
            $link = Cell::a($config->manager->slug . '/article/ignite', Config::speak('manager.title_new_', $speak->article));
            $link .= ' · ';
            $link .= Cell::a($config->manager->slug . '/page/ignite', Config::speak('manager.title_new_', $speak->page));
            $bars[$speak->add] = array('icon' => 'plus', 'url' => $config->manager->slug . '/article/ignite', 'description' => $link, 'stack' => 9.029999999999999);
        }
        Config::merge('manager_menu', $menus);
        Config::merge('manager_bar', $bars);
    });
}
// Loading frontend task(s) and route(s)
Weapon::add('routes_before', function () use($config, $speak) {
    require __DIR__ . DS . 'workers' . DS . 'task.comment.ignite.php';
    require __DIR__ . DS . 'workers' . DS . 'route.login.php';
});
// Add log in/out link in shield footer
function do_footer_manager_link($content, $path)
{
    global $config, $speak;
Пример #5
0
        ?>
"><?php 
        echo $page->date->FORMAT_3;
        ?>
</time>
      </span>
    </div>
    <div class="page-body"><?php 
        echo $page->description;
        ?>
</div>
    <div class="page-footer">
      <?php 
        Weapon::fire('page_footer', array($page));
        ?>
    </div>
  </li>
  <?php 
    }
    ?>
</ol>
<?php 
    include DECK . DS . 'workers' . DS . 'unit.pager.1.php';
} else {
    ?>
<p><?php 
    echo Config::speak('notify_empty', strtolower($speak->pages));
    ?>
</p>
<?php 
}
Пример #6
0
<?php

/**
 * Shortcode Manager
 * -----------------
 */
Route::accept($config->manager->slug . '/shortcode', function () use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $shortcodes = Get::state_shortcode(null, array(), false);
    $G = array('data' => $shortcodes);
    Config::set(array('page_title' => $speak->shortcodes . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.shortcode.php'));
    if ($request = Request::post()) {
        $request = Filter::apply('request:__shortcode', $request);
        Guardian::checkToken($request['token']);
        $data = array();
        for ($i = 0, $keys = $request['key'], $count = count($keys); $i < $count; ++$i) {
            if (trim($keys[$i]) !== "") {
                $data[$keys[$i]] = $request['value'][$i];
            }
        }
        $P = array('data' => $data);
        File::serialize($data)->saveTo(STATE . DS . 'shortcode.txt', 0600);
        Notify::success(Config::speak('notify_success_updated', $speak->shortcode));
        Weapon::fire('on_shortcode_update', array($G, $P));
        Guardian::kick($config->url_current);
    }
    Shield::lot(array('segment' => 'shortcode', 'files' => Mecha::O($shortcodes)))->attach('manager');
});
Пример #7
0
<?php

foreach ($field as $k => $v) {
    $f = $v['type'] === 'file' || $v['type'] === 'f';
    // Remove asset field value and data
    if (isset($v['remove']) && $f) {
        File::open(SUBSTANCE . DS . $v['remove'])->delete();
        Weapon::fire(array('on_substance_update', 'on_substance_destruct'), array($G, $P));
        Notify::success(Config::speak('notify_file_deleted', '<code>' . $v['remove'] . '</code>'));
        unset($field[$k]);
    }
    // Remove empty field value
    if (!isset($v['value']) || $v['value'] === "") {
        unset($field[$k]);
    } else {
        $e = File::E($v['value']);
        if (!file_exists(SUBSTANCE . DS . $e . DS . $v['value']) && $f) {
            unset($field[$k]);
        } else {
            $field[$k] = $v['value'];
        }
    }
}
Пример #8
0
 /**
  * ==========================================================
  *  RENDER A PAGE
  * ==========================================================
  *
  * -- CODE: -------------------------------------------------
  *
  *    Shield::attach('article');
  *
  * ----------------------------------------------------------
  *
  */
 public static function attach($name, $fallback = false, $buffer = true)
 {
     $path__ = File::path($name);
     $s = explode('-', File::N($name), 2);
     $G = array('data' => array('name' => $name, 'name_base' => $s[0]));
     if (strpos($path__, ROOT) === 0 && file_exists($path__) && is_file($path__)) {
         // do nothing ...
     } else {
         if ($_path = File::exist(self::path($path__, $fallback))) {
             $path__ = $_path;
         } else {
             if ($_path = File::exist(self::path($s[0], $fallback))) {
                 $path__ = $_path;
             } else {
                 Guardian::abort(Config::speak('notify_file_not_exist', '<code>' . $path__ . '</code>'));
             }
         }
     }
     $lot__ = self::cargo();
     $path__ = Filter::apply('shield:path', $path__);
     $G['data']['lot'] = $lot__;
     $G['data']['path'] = $path__;
     $G['data']['path_base'] = $s[0];
     $out = "";
     // Begin shield
     Weapon::fire('shield_lot_before', array($G, $G));
     extract(Filter::apply('shield:lot', $lot__));
     Weapon::fire('shield_lot_after', array($G, $G));
     Weapon::fire('shield_before', array($G, $G));
     if ($buffer) {
         ob_start(function ($content) use($path__, &$out) {
             $content = Filter::apply('shield:input', $content, $path__);
             $out = Filter::apply('shield:output', $content, $path__);
             return $out;
         });
         require $path__;
         ob_end_flush();
     } else {
         require $path__;
     }
     $G['data']['content'] = $out;
     // Reset shield lot
     self::$lot = array();
     // End shield
     Weapon::fire('shield_after', array($G, $G));
     exit;
 }
Пример #9
0
<?php

// The `__launch.php` file will be included only in the backend
Route::accept($config->manager->slug . '/plugin/' . File::B(__DIR__) . '/update', function () use($config, $speak) {
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        // [2]
        File::write('test!')->saveTo(__DIR__ . DS . 'states' . DS . 'config.txt', 0600);
        Notify::success(Config::speak('notify_success_updated', $speak->plugin));
        // [3]
        Guardian::kick(File::D($config->url_current));
        // [4]
    }
});
Пример #10
0
<div class="tab-content-area">
  <?php 
echo $messages;
?>
  <div class="tab-content" id="tab-content-1">
  <?php 
if ($file->configurator) {
    ?>
  <?php 
    include $file->configurator;
    ?>
  <?php 
} else {
    ?>
  <p><?php 
    echo Config::speak('notify_not_available', $speak->config);
    ?>
</p>
  <?php 
}
?>
  </div>
  <div class="tab-content hidden" id="tab-content-2">
    <p class="about-author">
    <?php 
echo Cell::strong($speak->author . ':') . ' ' . Text::parse($file->author, '->encoded_html');
if (isset($file->url) && $file->url !== '#') {
    ?>
 <?php 
    echo Cell::a($file->url, Jot::icon('external-link-square'), '_blank', array('class' => array('about-url', 'help'), 'title' => $speak->link, 'rel' => 'nofollow'));
    ?>
Пример #11
0
<?php

$post = 'page';
$response = 'comment';
// Repair
if (strpos($config->url_path, '/id:') !== false) {
    Weapon::add('tab_button_before', function ($page, $segment) use($config, $speak) {
        include __DIR__ . DS . 'unit' . DS . 'tab' . DS . 'button' . DS . 'new.php';
    }, 0.9);
    Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak) {
        include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'date.hidden.php';
    }, 0.9);
}
// You can't use index, tag, archive, search, manager and feed slug URL for page(s)
if ($slug = Request::post('slug')) {
    $s = array($config->index->slug => 1, $config->tag->slug => 1, $config->archive->slug => 1, $config->search->slug => 1, $config->manager->slug => 1, 'feed' => 1);
    if (isset($s[$slug])) {
        Notify::error(Config::speak('notify_error_slug_exist', $slug));
    }
}
require __DIR__ . DS . 'route.post.php';
        <?php 
echo Form::hidden('token', $token);
?>
        <p><?php 
echo Form::textarea('content', Guardian::wayback('content'), $speak->manager->placeholder_content, array('class' => array('textarea-block', 'textarea-expand', 'code')));
?>
</p>
        <p><?php 
echo Form::text('name', Guardian::wayback('name'), $speak->manager->placeholder_file_name);
?>
 <?php 
echo Jot::button('construct', $speak->create);
?>
</p>
        <p><?php 
echo Form::checkbox('redirect', 1, Request::method('get') ? false : Guardian::wayback('redirect', false), Config::speak('manager.description_redirect_to_', $speak->file));
?>
</p>
      </form>
    </div>
    <div class="tab-content hidden" id="tab-content-2">
      <?php 
$_files = array();
foreach (File::open(CACHE . DS . 'plugin.snippet.cache')->unserialize() as $_file) {
    $e = File::E($_file);
    if (!file_exists(ASSET . DS . '__snippet' . DS . $e . DS . $_file)) {
        continue;
    }
    $_files[] = File::url($_file);
}
?>
Пример #13
0
    if (!Guardian::happy(1) && Guardian::get('author') !== $post->author) {
        Shield::abort();
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . $post->title . $config->title_separator . $config->manager->title, 'page' => $post, 'cargo' => 'kill.post.php'));
    $G = array('data' => Mecha::A($post));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        File::open($post->path)->delete();
        // Deleting response(s) ...
        if ($responses = call_user_func('Get::' . $response . 's', 'DESC', 'post:' . $id, 'txt,hold')) {
            foreach ($responses as $v) {
                File::open($v)->delete();
            }
        }
        $P = array('data' => $request);
        include __DIR__ . DS . 'task.kill.substance.php';
        // Deleting custom CSS and JavaScript file of post ...
        File::open(CUSTOM . DS . Date::slug($id) . '.txt')->delete();
        File::open(CUSTOM . DS . Date::slug($id) . '.draft')->delete();
        Weapon::fire(array('on_custom_update', 'on_custom_destruct'), array($G, $P));
        // Deleting custom PHP file of post ...
        File::open(File::D($post->path) . DS . $post->slug . '.php')->delete();
        Notify::success(Config::speak('notify_success_deleted', $post->title));
        Weapon::fire(array('on_' . $segment . '_update', 'on_' . $segment . '_destruct'), array($G, $G));
        Guardian::kick($config->manager->slug . '/' . $segment);
    } else {
        Notify::warning(Config::speak('notify_confirm_delete_', '<strong>' . $post->title . '</strong>'));
        Notify::warning(Config::speak('notify_confirm_delete_page', strtolower($speak->{$segment}), strtolower($speak->{$response . 's'})));
    }
    Shield::lot(array('segment' => $segment))->attach('manager');
});
Пример #14
0
        <?php 
echo Form::text('slug', Guardian::wayback('slug', $default->slug), Text::parse($speak->manager->placeholder_title, '->slug'), array('class' => 'input-block'));
?>
        </span>
      </label>
      <?php 
include 'unit.composer.1.php';
?>
      <label class="grid-group">
        <span class="grid span-1 form-label"><?php 
echo $speak->description;
?>
</span>
        <span class="grid span-5">
        <?php 
echo Form::textarea('description', Guardian::wayback('description', $default->description), Config::speak('manager.placeholder_description_', strtolower($speak->article)), array('class' => 'textarea-block'));
?>
        </span>
      </label>
      <?php 
$tags = array();
$tags_wayback = ',' . implode(',', Guardian::wayback('kind', Mecha::A($default->kind))) . ',';
foreach (Get::tags() as $tag) {
    if ($tag && $tag->id !== 0) {
        $tags[] = '<div>' . Form::checkbox('kind[]', $tag->id, strpos($tags_wayback, ',' . $tag->id . ',') !== false, $tag->name) . '</div>';
    }
}
?>
      <?php 
if (count($tags) > 0) {
    ?>
Пример #15
0
?>
</h3>
      <?php 
echo Jot::uploader($config->manager->slug . '/shield', 'zip');
?>
      <hr>
      <?php 
echo Guardian::wizard($segment);
?>
    </div>
    <?php 
if (count($folders) > 1) {
    ?>
    <div class="tab-content hidden" id="tab-content-3">
      <h3><?php 
    echo Config::speak('manager.title_your_', $speak->shields);
    ?>
</h3>
      <?php 
    foreach ($folders as $folder) {
        $folder = File::B($folder);
        ?>
      <?php 
        if ($config->shield !== $folder && strpos($folder, '__') !== 0) {
            ?>
      <?php 
            $r = SHIELD . DS . $folder . DS;
            $c = File::exist($r . 'capture.png');
            ?>
      <?php 
            $page = Shield::info($folder);
Пример #16
0
<p><?php 
echo Config::speak('notify_error__not_found', strpos($speak->notify_error__not_found, '%s') === 0 ? $s : strtolower($s));
?>
</p>
    if (trim($request['name']) === "") {
        $request['name'] = $id . '.txt';
        // empty file name
    }
    $_path = Text::parse(sprintf($request['name'], $id), '->safe_path_name');
    $e = File::E($_path, false);
    if ($e !== 'txt' && $e !== 'php') {
        $e = 'txt';
        $_path .= '.txt';
    }
    $_path_ = File::path($_path);
    $file = ASSET . DS . '__snippet' . DS . $e . DS . $_path;
    if (File::exist($file)) {
        // file already exists
        Notify::error(Config::speak('notify_file_exist', '<code>' . $_path_ . '</code>'));
    }
    if (trim($request['content']) === "") {
        // empty file content
        Notify::error($speak->notify_error_content_empty);
    }
    if (!Notify::errors()) {
        $recent = array_slice(File::open(CACHE . DS . 'plugin.snippet.cache')->unserialize(), 0, $config->per_page);
        File::serialize(array_merge(array($_path), $recent))->saveTo(CACHE . DS . 'plugin.snippet.cache', 0600);
        $url = $config->manager->slug . '/asset/repair/file:__snippet/' . $e . '/' . File::url($_path) . '?path=' . urlencode(rtrim('__snippet/' . $e . '/' . File::D(File::url($_path)), '/'));
        File::write($request['content'])->saveTo($file, 0600);
        Notify::success(Config::speak('notify_file_created', '<code>' . $_path_ . '</code>' . (!isset($request['redirect']) ? ' <a class="pull-right" href="' . $config->url . '/' . $url . '" target="_blank">' . Jot::icon('pencil') . ' ' . $speak->edit . '</a>' : "")));
        Notify::info('<strong>' . $speak->shortcode . ':</strong> <code>{{' . ($e === 'php' ? 'include' : 'print') . ':' . str_replace('.' . $e . X, "", File::url($_path) . X) . '}}</code>');
        Guardian::kick(isset($request['redirect']) ? $url : File::D($config->url_current));
    }
    Guardian::kick(File::D($config->url_current));
});
Пример #18
0
 /**
  * ==========================================================================
  *  EXTRACT PAGE FILE INTO LIST OF PAGE DATA FROM ITS PATH/SLUG/ID
  * ==========================================================================
  *
  * -- CODE: -----------------------------------------------------------------
  *
  *    var_dump(Get::page('about'));
  *
  * --------------------------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter  | Type   | Description
  *  ---------- | ------ | ---------------------------------------------------
  *  $reference | mixed  | Slug, ID, path or array of `Get::pageExtract()`
  *  $excludes  | array  | Exclude some field(s) from result(s)
  *  $folder    | string | Folder of the page(s)
  *  $connector | string | Path connector for page URL
  *  $FP        | string | Filter prefix for `Text::toPage()`
  *  ---------- | ------ | ---------------------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function page($reference, $excludes = array(), $folder = PAGE, $connector = '/', $FP = 'page:')
 {
     $config = Config::get();
     $speak = Config::speak();
     $excludes = array_flip($excludes);
     $results = false;
     // From `Get::pageExtract()`
     if (is_array($reference)) {
         $results = $reference;
     } else {
         // By path => `cabinet\pages\0000-00-00-00-00-00_1,2,3_page-slug.txt`
         if (strpos($reference, $folder) === 0) {
             $results = self::pageExtract($reference, $FP);
         } else {
             // By slug => `page-slug` or by ID => 12345
             $results = self::pageExtract(self::pagePath($reference, $folder), $FP);
         }
     }
     if (!$results || !file_exists($results['path'])) {
         return false;
     }
     /**
      * RULES: Do not do any tags looping, content Markdown-ing
      * and external file requesting if it has been marked as
      * the excluded field(s). For better performance.
      */
     $results = $results + Text::toPage(File::open($results['path'])->read(), isset($excludes['content']) ? false : 'content', $FP);
     $content = isset($results['content_raw']) ? $results['content_raw'] : "";
     $time = str_replace(array(' ', ':'), '-', $results['time']);
     $extension = File::E($results['path']);
     if ($php_file = File::exist(File::D($results['path']) . DS . $results['slug'] . '.php')) {
         ob_start();
         include $php_file;
         $results['content'] = ob_get_clean();
     }
     $results['date'] = self::AMF(Date::extract($results['time']), $FP, 'date');
     $results['url'] = self::AMF($config->url . $connector . $results['slug'], $FP, 'url');
     $results['link'] = "";
     $results['excerpt'] = "";
     if (!isset($results['author'])) {
         $results['author'] = self::AMF($config->author, $FP, 'author');
     }
     if (!isset($results['description'])) {
         $summary = Converter::curt($content, $config->excerpt_length, $config->excerpt_tail);
         $results['description'] = self::AMF($summary, $FP, 'description');
     }
     $content_test = isset($excludes['content']) && strpos($content, '<!--') !== false ? Text::toPage(Text::ES($content), 'content', $FP) : $results;
     $content_test = $content_test['content'];
     $content_test = is_array($content_test) ? implode("", $content_test) : $content_test;
     // Redirect 301 with `<!-- kick: "http://example.com" -->`
     if (strpos($content_test, '<!-- kick:') !== false && $config->page_type === rtrim($FP, ':')) {
         preg_match('#<!-- kick\\: *([\'"]?)(.*?)\\1 -->#', $content_test, $matches);
         Guardian::kick($matches[2]);
     }
     // External link with `<!-- link: "http://example.com" -->`
     if (strpos($content_test, '<!-- link:') !== false) {
         preg_match('#<!-- link\\: *([\'"]?)(.*?)\\1 -->#', $content_test, $matches);
         $results['link'] = $matches[2];
         $results['content'] = preg_replace('#<!-- link\\:.*? -->#', "", $results['content']);
     }
     // Manual post excerpt with `<!-- cut+ "Read More" -->`
     if (strpos($content_test, '<!-- cut+ ') !== false) {
         preg_match('#<!-- cut\\+( +([\'"]?)(.*?)\\2)? -->#', $content_test, $matches);
         $more = !empty($matches[3]) ? $matches[3] : $speak->read_more;
         $content_test = preg_replace('#<!-- cut\\+( +(.*?))? -->#', '<p><a class="fi-link" href="' . $results['url'] . '#read-more:' . $results['id'] . '">' . $more . '</a></p><!-- cut -->', $content_test);
     }
     // ... or `<!-- cut -->`
     if (strpos($content_test, '<!-- cut -->') !== false) {
         $parts = explode('<!-- cut -->', $content_test, 2);
         $results['excerpt'] = self::AMF(trim($parts[0]), $FP, 'excerpt');
         $results['content'] = preg_replace('#<p><a class="fi-link" href=".*?">.*?<\\/a><\\/p>#', "", trim($parts[0])) . NL . NL . '<span class="fi" id="read-more:' . $results['id'] . '" aria-hidden="true"></span>' . NL . NL . trim($parts[1]);
     }
     if (!isset($excludes['tags'])) {
         $tags = array();
         foreach ($results['kind'] as $id) {
             $tags[] = self::rawTag($id);
         }
         $results['tags'] = self::AMF(Mecha::eat($tags)->order('ASC', 'name')->vomit(), $FP, 'tags');
     }
     if (!isset($excludes['css']) || !isset($excludes['js'])) {
         if ($file = File::exist(CUSTOM . DS . $time . '.' . $extension)) {
             $custom = explode(SEPARATOR, File::open($file)->read());
             $css = isset($custom[0]) ? Text::DS(trim($custom[0])) : "";
             $js = isset($custom[1]) ? Text::DS(trim($custom[1])) : "";
             /**
              * CSS
              * ---
              *
              * css_raw
              * page:css_raw
              * custom:css_raw
              *
              * shortcode
              * page:shortcode
              * custom:shortcode
              *
              * css
              * page:css
              * custom:css
              *
              */
             $css = self::AMF($css, $FP, 'css_raw');
             $results['css_raw'] = Filter::apply('custom:css_raw', $css);
             $css = self::AMF($css, $FP, 'shortcode');
             $css = Filter::apply('custom:shortcode', $css);
             $css = self::AMF($css, $FP, 'css');
             $results['css'] = Filter::apply('custom:css', $css);
             /**
              * JS
              * --
              *
              * js_raw
              * page:js_raw
              * custom:js_raw
              *
              * shortcode
              * page:shortcode
              * custom:shortcode
              *
              * js
              * page:js
              * custom:js
              *
              */
             $js = self::AMF($js, $FP, 'js_raw');
             $results['js_raw'] = Filter::apply('custom:js_raw', $js);
             $js = self::AMF($js, $FP, 'shortcode');
             $js = Filter::apply('custom:shortcode', $js);
             $js = self::AMF($js, $FP, 'js');
             $results['js'] = Filter::apply('custom:js', $js);
         } else {
             $results['css'] = $results['js'] = $results['css_raw'] = $results['js_raw'] = "";
         }
         $custom = $results['css'] . $results['js'];
     } else {
         $custom = "";
     }
     $results['images'] = self::AMF(self::imagesURL($results['content'] . $custom), $FP, 'images');
     $results['image'] = self::AMF(isset($results['images'][0]) ? $results['images'][0] : Image::placeholder(), $FP, 'image');
     $comments = self::comments($results['id'], 'ASC', Guardian::happy() ? 'txt,hold' : 'txt');
     $results['total_comments'] = self::AMF($comments !== false ? count($comments) : 0, $FP, 'total_comments');
     $results['total_comments_text'] = self::AMF($results['total_comments'] . ' ' . ($results['total_comments'] === 1 ? $speak->comment : $speak->comments), $FP, 'total_comments_text');
     if (!isset($excludes['comments'])) {
         if ($comments) {
             $results['comments'] = array();
             foreach ($comments as $comment) {
                 $results['comments'][] = self::comment($comment);
             }
             $results['comments'] = self::AMF($results['comments'], $FP, 'comments');
         }
     }
     unset($comments);
     /**
      * Custom Field(s)
      * ---------------
      */
     if (!isset($excludes['fields'])) {
         /**
          * Initialize custom field(s) with the default value(s) so that
          * user(s) don't have to write `isset()` function multiple time(s)
          * just to prevent error message(s) because of the object key(s)
          * that is not available in the old post(s).
          */
         $fields = self::state_field(rtrim($FP, ':'), null, array(), false);
         $init = array();
         foreach ($fields as $key => $value) {
             $init[$key] = $value['value'];
         }
         /**
          * Start re-writing ...
          */
         if (isset($results['fields']) && is_array($results['fields'])) {
             foreach ($results['fields'] as $key => $value) {
                 if (is_array($value) && isset($value['type'])) {
                     // <= 1.1.3
                     $value = isset($value['value']) ? $value['value'] : false;
                 }
                 $init[$key] = self::AMF($value, $FP, 'fields.' . $key);
             }
         }
         $results['fields'] = $init;
         unset($fields, $init);
     }
     /**
      * Exclude some field(s) from result(s)
      */
     foreach ($results as $key => $value) {
         if (isset($excludes[$key])) {
             unset($results[$key]);
         }
     }
     return Mecha::O($results);
 }
Пример #19
0
    </fieldset>
    <?php 
}
?>
  </fieldset>
  <fieldset>
    <legend><?php 
echo $speak->default;
?>
</legend>
    <?php 
foreach (array('article', 'page') as $page) {
    ?>
    <fieldset>
      <legend><?php 
    $title = Config::speak($page);
    echo $title;
    ?>
</legend>
      <label class="grid-group">
        <span class="grid span-2 form-label"><?php 
    echo $speak->title;
    ?>
</span>
        <span class="grid span-4">
        <?php 
    echo Form::text('defaults[' . $page . '_title]', Guardian::wayback('defaults.' . $page . '_title', Config::get('defaults.' . $page . '_title')), null, array('class' => 'input-block'));
    ?>
        </span>
      </label>
      <label class="grid-group">
Пример #20
0
         $message = $request['message'];
         $field = Request::post('fields', array());
         include DECK . DS . 'workers' . DS . 'task.field.1.php';
         // Temporarily disallow image(s) in comment to prevent XSS
         $message = strip_tags($message, '<br><img>' . ($parser === 'HTML' ? '<a><abbr><b><blockquote><code><del><dfn><em><i><ins><p><pre><span><strong><sub><sup><time><u><var>' : ""));
         $message = preg_replace('#(\\!\\[.*?\\]\\(.*?\\))#', '`$1`', $message);
         $message = preg_replace('#<img(\\s[^<>]*?)>#', '&lt;img$1&gt;', $message);
         Page::header(array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => Guardian::happy() ? 'pilot' : 'passenger', 'Content Type' => $parser, 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false, 'UA' => Get::UA(), 'IP' => Get::IP()))->content($message)->saveTo(RESPONSE . DS . $post . '_' . Date::format($id, 'Y-m-d-H-i-s') . '_' . ($parent ? Date::format($parent, 'Y-m-d-H-i-s') : '0000-00-00-00-00-00') . $extension);
         Notify::success(Config::speak('notify_success_submitted', $speak->comment));
         if ($extension === '.hold') {
             Notify::info($speak->notify_info_comment_moderation);
         }
         Weapon::fire('on_comment_update', array($P, $P));
         Weapon::fire('on_comment_construct', array($P, $P));
         if ($config->comment_notification_email) {
             $mail = '<p>' . Config::speak('comment_notification', $article->url . '#' . sprintf($comment_id, Date::format($id, 'U'))) . '</p>';
             $mail .= '<p><strong>' . $name . ':</strong></p>';
             $mail .= $parser !== 'HTML' ? Text::parse($message, '->html') : $message;
             $mail .= '<p>' . Date::format($id, 'Y/m/d H:i:s') . '</p>';
             // Sending email notification ...
             if (!Guardian::happy()) {
                 if (Notify::send($request['email'], $config->author_email, $speak->comment_notification_subject, $mail, 'comment:')) {
                     Weapon::fire('on_comment_notification_construct', array($request, $config->author_email, $speak->comment_notification_subject, $mail));
                 }
             }
         }
         Guardian::kick($config->url_current . (!Guardian::happy() && $config->comment_moderation ? '#' . $comment_form_id : '#' . sprintf($comment_id, Date::format($id, 'U'))));
     } else {
         Guardian::kick($config->url_current . '#' . $comment_form_id);
     }
 }
Пример #21
0
 public static function size($file, $unit = null, $precision = 2)
 {
     $size = is_numeric($file) ? $file : filesize($file);
     $base = log($size, 1024);
     $suffix = array('B', 'KB', 'MB', 'GB', 'TB');
     if (!($u = array_search((string) $unit, $suffix))) {
         $u = $size > 0 ? floor($base) : 0;
     }
     $output = round($size / pow(1024, $u), $precision);
     return $output < 0 ? Config::speak('unknown') : trim($output . ' ' . $suffix[$u]);
 }
Пример #22
0
<?php

/**
 * Menu Manager
 * ------------
 */
Route::accept($config->manager->slug . '/menu', function () use($config, $speak) {
    if (Guardian::get('status') !== 'pilot') {
        Shield::abort();
    }
    $menus = Get::state_menu();
    Config::set(array('page_title' => $speak->menus . $config->title_separator . $config->manager->title, 'cargo' => DECK . DS . 'workers' . DS . 'cargo.menu.php'));
    $G = array('data' => array('content' => $menus));
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        // Check for invalid input
        if (preg_match('#(^|\\n)(\\t| {1,3})(?:[^ ])#', $request['content'])) {
            Notify::error($speak->notify_invalid_indent_character);
            Guardian::memorize($request);
        }
        $P = array('data' => $request);
        if (!Notify::errors()) {
            File::write($request['content'])->saveTo(STATE . DS . 'menu.txt', 0600);
            Notify::success(Config::speak('notify_success_updated', $speak->menu));
            Weapon::fire('on_menu_update', array($G, $P));
            Guardian::kick($config->url_current);
        }
    }
    Shield::lot(array('segment' => 'menu', 'the_content' => $menus))->attach('manager', false);
});
Пример #23
0
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        $info_path = array();
        $is_folder_or_file = count($deletes) === 1 && is_dir(ASSET . DS . $deletes[0]) ? 'folder' : 'file';
        foreach ($deletes as $file_to_delete) {
            $_path = ASSET . DS . $file_to_delete;
            $info_path[] = $_path;
            File::open($_path)->delete();
        }
        $P = array('data' => array('files' => $info_path));
        Notify::success(Config::speak('notify_' . $is_folder_or_file . '_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>'));
        Weapon::fire('on_asset_update', array($P, $P));
        Weapon::fire('on_asset_destruct', array($P, $P));
        Guardian::kick($config->manager->slug . '/asset/1' . $p);
    } else {
        Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . File::path($name) . '</code>') : $speak->notify_confirm_delete);
    }
    Shield::lot('segment', 'asset')->attach('manager', false);
});
/**
 * Multiple Asset Killer
 * ---------------------
 */
Route::accept($config->manager->slug . '/asset/kill', function ($path = "") use($config, $speak) {
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        if (!isset($request['selected'])) {
            Notify::error($speak->notify_error_no_files_selected);
            Guardian::kick($config->manager->slug . '/asset/1');
        }
        $files = array();
Пример #24
0
        ?>
" title="<?php 
        echo $speak->permalink;
        ?>
" rel="nofollow" target="_blank">#</a>
      </span>
    </div>
    <div class="page-body"><?php 
        echo $response->message;
        ?>
</div>
    <div class="page-footer">
      <?php 
        Weapon::fire('comment_footer', array($response, $article = false));
        ?>
    </div>
  </li>
  <?php 
    }
    ?>
</ol>
<?php 
    include DECK . DS . 'workers' . DS . 'unit.pager.1.php';
} else {
    ?>
<p><?php 
    echo Config::speak('notify_empty', strtolower($speak->comments));
    ?>
</p>
<?php 
}
Пример #25
0
<?php

/**
 * Error Log
 * ---------
 */
Route::accept($config->manager->slug . '/error', function () use($config, $speak) {
    Config::set(array('page_title' => $speak->errors . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.error.php'));
    Shield::lot(array('segment' => 'error', 'content' => File::open(ini_get('error_log'))->read(false)))->attach('manager');
});
/**
 * Error Log Killer
 * ----------------
 */
Route::accept($config->manager->slug . '/error/kill', function () use($config, $speak) {
    if (!Guardian::happy(1)) {
        Shield::abort();
    }
    $errors = LOG . DS . 'errors.log';
    $G = array('data' => array('content' => File::open($errors)->read()));
    File::open($errors)->delete();
    Weapon::fire('on_error_destruct', array($G, $G));
    Notify::success(Config::speak('notify_success_deleted', $speak->file));
    Guardian::kick(File::D($config->url_current));
});
Пример #26
0
 *
 * -- CODE: -------------------------------------------------
 *
 *    $input = '2014-05-30 09:22:42';
 *
 *    var_dump(Date::extract($input));
 *
 * ----------------------------------------------------------
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *  Parameter | Type  | Description
 *  --------- | ----- | -------------------------------------
 *  $date     | mixed | The date input
 *  --------- | ----- | -------------------------------------
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 */
Date::plug('extract', function ($date, $output = null) {
    $speak = Config::speak();
    $month_name = (array) $speak->month_names;
    $day_name = (array) $speak->day_names;
    $month_name_short = (array) $speak->month_names_short;
    $day_name_short = (array) $speak->day_names_short;
    list($year, $year_short, $month, $day, $hour_24, $hour_12, $minute, $second, $AP, $d) = explode('.', Date::format($date, 'Y.y.m.d.H.h.i.s.A.w'));
    $month_name = $month_name[(int) $month - 1];
    $day_name = $day_name[(int) $d];
    $month_name_short = $month_name_short[(int) $month - 1];
    $day_name_short = $day_name_short[(int) $d];
    $results = array('unix' => (int) Date::format($date, 'U'), 'W3C' => Date::format($date, 'c'), 'GMT' => Date::GMT($date, 'Y-m-d H:i:s'), 'slug' => $year . '-' . $month . '-' . $day . '-' . $hour_24 . '-' . $minute . '-' . $second, 'year' => $year, 'year_short' => $year_short, 'month' => $month, 'day' => $day, 'month_number' => (int) $month, 'day_number' => (int) $day, 'month_name' => $month_name, 'day_name' => $day_name, 'month_name_short' => $month_name_short, 'day_name_short' => $day_name_short, 'hour' => $hour_24, 'hour_12' => $hour_12, 'hour_24' => $hour_24, 'minute' => $minute, 'second' => $second, 'hour_number' => (int) $hour_24, 'hour_12_number' => (int) $hour_12, 'hour_24_number' => (int) $hour_24, 'minute_number' => (int) $minute, 'second_number' => (int) $second, 'AM_PM' => $AP, 'FORMAT_1' => $day_name . ', ' . $day . ' ' . $month_name . ' ' . $year, 'FORMAT_2' => $day_name . ', ' . $month_name . ' ' . $day . ', ' . $year, 'FORMAT_3' => $year . '/' . $month . '/' . $day . ' ' . $hour_24 . ':' . $minute . ':' . $second, 'FORMAT_4' => $year . '/' . $month . '/' . $day . ' ' . $hour_12 . ':' . $minute . ':' . $second . ' ' . $AP, 'FORMAT_5' => $hour_24 . ':' . $minute, 'FORMAT_6' => $hour_12 . ':' . $minute . ' ' . $AP);
    return !is_null($output) ? $results[$output] : $results;
});
Пример #27
0
 /**
  * ============================================================================
  *  PAGINATION EXTRACTOR FOR LIST OF FILE(S)
  * ============================================================================
  *
  * -- CODE: -------------------------------------------------------------------
  *
  *    $pager = Navigator::extract(glob('some/files/*.txt'), 1, 5, 'foo/bar');
  *    echo $pager->prev->anchor;
  *
  * ----------------------------------------------------------------------------
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *  Parameter  | Type    | Description
  *  ---------- | ------- | ----------------------------------------------------
  *  $pages     | array   | Array of file(s) to be paginated
  *  $current   | integer | The current page offset
  *  $current   | string  | The current page path
  *  $per_page  | integer | Number of file(s) to show per page request
  *  $connector | string  | Extra path to be inserted into URL
  *  ---------- | ------- | ----------------------------------------------------
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  */
 public static function extract($pages = array(), $current = 1, $per_page = 10, $connector = '/')
 {
     // Set default next, previous and step data
     $bucket = array('prev' => false, 'next' => false, 'step' => false);
     $pages = (array) $pages;
     $config = Config::get();
     $speak = Config::speak();
     $base = $config->url;
     $q = str_replace('&', '&amp;', $config->url_query);
     $qq = strpos($connector, '?') !== false ? str_replace('?', '&amp;', $q) : $q;
     $total = count($pages);
     $c = self::$config;
     if (strpos($connector, '%s') === false) {
         if (trim($connector, '/') !== "") {
             $connector = '/' . trim($connector, '/') . '/%s';
         } else {
             $connector = '/%s';
         }
     }
     if (is_int($current)) {
         $current = (int) $current;
         $prev = $current > 1 ? $current - 1 : false;
         $next = $current < ceil($total / $per_page) ? $current + 1 : false;
         // Generate next/previous URL for index page
         $bucket['prev']['url'] = Filter::apply(array('pager:prev.url', 'pager:url', 'url'), $prev ? $base . sprintf($connector, $prev) . $qq : $base . $q, $prev, $connector);
         $bucket['next']['url'] = Filter::apply(array('pager:next.url', 'pager:url', 'url'), $next ? $base . sprintf($connector, $next) . $qq : $base . $q, $next, $connector);
         // Generate next/previous anchor for index page
         $bucket['prev']['anchor'] = Filter::apply(array('pager:prev.anchor', 'pager:anchor', 'anchor'), $prev ? '<a href="' . $bucket['prev']['url'] . '" rel="prev">' . $speak->newer . '</a>' : "", $prev, $connector);
         $bucket['next']['anchor'] = Filter::apply(array('pager:next.anchor', 'pager:anchor', 'anchor'), $next ? '<a href="' . $bucket['next']['url'] . '" rel="next">' . $speak->older . '</a>' : "", $next, $connector);
         // Generate pagination anchor(s) for index page
         $html = '<span' . ($c['classes']['pagination'] !== false ? ' class="' . $c['classes']['pagination'] . '"' : "") . '>';
         $chunk = (int) ceil($total / $per_page);
         $step = $chunk > self::$config['step'] ? self::$config['step'] : $chunk;
         $left = $current - $step;
         if ($left < 1) {
             $left = 1;
         }
         if ($chunk > 1) {
             $bucket['step']['url']['first'] = Filter::apply(array('pager:step.url', 'pager:url', 'url'), $prev ? $base . sprintf($connector, 1) . $qq : false, 1, $connector);
             $bucket['step']['url']['prev'] = Filter::apply(array('pager:step.url', 'pager:url', 'url'), $prev ? $base . sprintf($connector, $prev) . $qq : false, $prev, $connector);
             $bucket['step']['anchor']['first'] = Filter::apply(array('pager:step.anchor', 'pager:anchor', 'anchor'), $prev ? '<a href="' . $bucket['step']['url']['first'] . '">' . $speak->first . '</a>' : '<span>' . $speak->first . '</span>', 1, $connector);
             $bucket['step']['anchor']['prev'] = Filter::apply(array('pager:step.anchor', 'pager:anchor', 'anchor'), $prev ? '<a href="' . $bucket['step']['url']['prev'] . '" rel="prev">' . $speak->prev . '</a>' : '<span>' . $speak->prev . '</span>', $prev, $connector);
             $html .= $bucket['step']['anchor']['first'] . $bucket['step']['anchor']['prev'];
             $html .= '<span>';
             for ($i = $current - $step + 1; $i < $current + $step; ++$i) {
                 if ($chunk > 1) {
                     if ($i - 1 < $chunk && ($i > 0 && $i + 1 > $current - $left - round($chunk / 2))) {
                         $bucket['step']['url'][$i] = Filter::apply(array('pager:step.url', 'pager:url'), $i !== $current ? $base . sprintf($connector, $i) . $qq : false, $i, $connector);
                         $bucket['step']['anchor'][$i] = Filter::apply(array('pager:step.anchor', 'pager:anchor', 'anchor'), $i !== $current ? '<a href="' . $bucket['step']['url'][$i] . '">' . $i . '</a>' : '<strong' . ($c['classes']['current'] !== false ? ' class="' . $c['classes']['current'] . '"' : "") . '>' . $i . '</strong>', $i, $connector);
                         $html .= $bucket['step']['anchor'][$i];
                     }
                 }
             }
             $html .= '</span>';
             $bucket['step']['url']['next'] = Filter::apply(array('pager:step.url', 'pager:url', 'url'), $next ? $base . sprintf($connector, $next) . $qq : false, $next, $connector);
             $bucket['step']['url']['last'] = Filter::apply(array('pager:step.url', 'pager:url', 'url'), $next ? $base . sprintf($connector, $chunk) . $qq : false, $chunk, $connector);
             $bucket['step']['anchor']['next'] = Filter::apply(array('pager:step.anchor', 'pager:anchor'), $next ? '<a href="' . $bucket['step']['url']['next'] . '" rel="next">' . $speak->next . '</a>' : '<span>' . $speak->next . '</span>', $next, $connector);
             $bucket['step']['anchor']['last'] = Filter::apply(array('pager:step.anchor', 'pager:anchor'), $next ? '<a href="' . $bucket['step']['url']['last'] . '">' . $speak->last . '</a>' : '<span>' . $speak->last . '</span>', $chunk, $connector);
             $html .= $bucket['step']['anchor']['next'] . $bucket['step']['anchor']['last'];
         }
         $bucket['step']['html'] = Filter::apply('pager:step.html', $html . '</span>');
     }
     if (is_string($current)) {
         for ($i = 0; $i < $total; ++$i) {
             if ($pages[$i] === $current) {
                 $prev = isset($pages[$i - 1]) ? $pages[$i - 1] : false;
                 $next = isset($pages[$i + 1]) ? $pages[$i + 1] : false;
                 // Generate next/previous URL for single page
                 $bucket['prev']['url'] = Filter::apply(array('pager:prev.url', 'pager:url', 'url'), $prev ? $base . sprintf($connector, $prev) . $qq : $base . $q, $prev, $connector);
                 $bucket['next']['url'] = Filter::apply(array('pager:next.url', 'pager:url', 'url'), $next ? $base . sprintf($connector, $next) . $qq : $base . $q, $next, $connector);
                 // Generate next/previous anchor for single page
                 $bucket['prev']['anchor'] = Filter::apply(array('pager:prev.anchor', 'pager:anchor', 'anchor'), $bucket['prev']['url'] !== $base ? '<a href="' . $bucket['prev']['url'] . '" rel="prev">' . $speak->newer . '</a>' : "", $prev, $connector);
                 $bucket['next']['anchor'] = Filter::apply(array('pager:next.anchor', 'pager:anchor', 'anchor'), $bucket['next']['url'] !== $base ? '<a href="' . $bucket['next']['url'] . '" rel="next">' . $speak->older . '</a>' : "", $next, $connector);
                 break;
             }
         }
     }
     return Mecha::O($bucket);
 }
Пример #28
0
function do_meta_3()
{
    $config = Config::get();
    $speak = Config::speak();
    $html = Cell::link(Filter::colon('favicon:url', $config->url . '/favicon.ico'), 'shortcut icon', 'image/x-icon', array(), 2) . NL;
    $html .= Cell::link(Filter::colon('canonical:url', $config->url_current), 'canonical', null, array(), 2) . NL;
    $html .= Cell::link(Filter::colon('sitemap:url', $config->url . '/sitemap'), 'sitemap', null, array(), 2) . NL;
    $html .= Cell::link(Filter::colon('feed:url', $config->url . '/feed/rss'), 'alternate', 'application/rss+xml', array('title' => $speak->feeds . $config->title_separator . $config->title), 2) . O_END;
    echo Filter::apply('meta', $html, 3);
}
Пример #29
0
    } else {
        Notify::warning(Config::speak('notify_confirm_delete_', $path ? '<code>' . File::path($path) . '</code>' : '<strong>' . $info['title'] . '</strong>'));
    }
    Shield::lot(array('segment' => 'shield', 'the_shield' => $folder, 'the_name' => $path, 'the_info' => $info))->attach('manager', false);
});
/**
 * Shield Attacher
 * ---------------
 */
Route::accept($config->manager->slug . '/shield/(attach|eject)/id:(:any)', function ($path = "", $slug = "") use($config, $speak) {
    $new_config = Get::state_config();
    $new_config['shield'] = $path === 'attach' ? $slug : 'normal';
    File::serialize($new_config)->saveTo(STATE . DS . 'config.txt', 0600);
    $G = array('data' => array('id' => $slug, 'action' => $path));
    $mode = $path === 'eject' ? 'eject' : 'mount';
    Notify::success(Config::speak('notify_success_updated', $speak->shield));
    Weapon::fire('on_shield_update', array($G, $G));
    Weapon::fire('on_shield_' . $mode, array($G, $G));
    Weapon::fire('on_shield_' . md5($slug) . '_update', array($G, $G));
    Weapon::fire('on_shield_' . md5($slug) . '_' . $mode, array($G, $G));
    foreach (glob(SYSTEM . DS . 'log' . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
        File::open($asset_cache)->delete();
    }
    Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
/**
 * Shield Backup
 * -------------
 */
Route::accept($config->manager->slug . '/shield/backup/id:(:any)', function ($folder = "") use($config, $speak) {
    $name = $folder . '.zip';
Пример #30
0
 function do_comment_construct()
 {
     $config = Config::get();
     $speak = Config::speak();
     if ($config->page_type === 'article') {
         $comment_id = 'comment-%d';
         // Your comment ID
         $comment_form_id = 'comment-form';
         // Your comment form ID
         $article = isset($config->article->path) ? $config->article : false;
         $G = array('data' => array('article' => Mecha::A($article), 'comment_id' => $comment_id, 'comment_form_id' => $comment_form_id));
         if ($article !== false && ($request = Request::post())) {
             if ($task = File::exist(SHIELD . DS . $config->shield . DS . 'workers' . DS . 'task.comment.php')) {
                 require $task;
                 // Custom comment constructor
             } else {
                 // Check token
                 Guardian::checkToken($request['token'], $article->url . '#' . $comment_form_id);
                 $extension = $config->comments->moderation && !Guardian::happy() ? '.hold' : '.txt';
                 // Check name
                 if (trim($request['name']) === "") {
                     Notify::error(Config::speak('notify_error_empty_field', $speak->name));
                 }
                 // Check email
                 if (trim($request['email']) !== "") {
                     if (!Guardian::check($request['email'], '->email')) {
                         Notify::error($speak->notify_invalid_email);
                     } else {
                         // Disallow passenger(s) from entering your email address in the comment email field
                         if (!Guardian::happy() && $request['email'] === $config->author->email) {
                             Notify::warning(Config::speak('notify_warning_forbidden_input', array('<em>' . $request['email'] . '</em>', strtolower($speak->email))));
                         }
                     }
                 } else {
                     Notify::error(Config::speak('notify_error_empty_field', $speak->email));
                 }
                 // Check URL
                 if (trim($request['url']) !== "" && !Guardian::check($request['url'], '->url')) {
                     Notify::error($speak->notify_invalid_url);
                 }
                 // Check message
                 if (trim($request['message']) === "") {
                     Notify::error(Config::speak('notify_error_empty_field', $speak->message));
                 }
                 // Check challenge
                 if (!Guardian::checkMath($request['math'])) {
                     Notify::error($speak->notify_invalid_math_answer);
                 }
                 // Check name length
                 if (Guardian::check($request['name'], '->too_long', 100)) {
                     Notify::error(Config::speak('notify_error_too_long', $speak->name));
                 }
                 // Check email length
                 if (Guardian::check($request['email'], '->too_long', 100)) {
                     Notify::error(Config::speak('notify_error_too_long', $speak->email));
                 }
                 // Check URL length
                 if (Guardian::check($request['url'], '->too_long', 100)) {
                     Notify::error(Config::speak('notify_error_too_long', $speak->url));
                 }
                 // Check message length
                 if (Guardian::check($request['message'], '->too_long', 1700)) {
                     Notify::error(Config::speak('notify_error_too_long', $speak->message));
                 }
                 // Check for spam keyword(s) in comment
                 $fucking_words = explode(',', $config->keywords_spam);
                 foreach ($fucking_words as $spam) {
                     if ($f**k = trim($spam)) {
                         if ($request['email'] === $f**k || strpos(strtolower($request['message']), strtolower($f**k)) !== false) {
                             Notify::warning($speak->notify_warning_intruder_detected . ' <strong class="text-error pull-right">' . $f**k . '</strong>');
                             break;
                         }
                     }
                 }
                 if (!Notify::errors()) {
                     $post = Date::slug($article->time);
                     $id = (int) time();
                     $parent = Request::post('parent');
                     $P = array('data' => $request);
                     $P['data']['id'] = $id;
                     $name = strip_tags($request['name']);
                     $email = Text::parse($request['email'], '->broken_entity');
                     $url = isset($request['url']) && trim($request['url']) !== "" ? $request['url'] : false;
                     $parser = strip_tags(Request::post('content_type', $config->html_parser->active));
                     $message = Text::parse($request['message'], '->text', WISE_CELL . '<img>', false);
                     $field = Request::post('fields', array());
                     include File::D(__DIR__, 2) . DS . 'task.fields.php';
                     // Temporarily disallow image(s) in comment to prevent XSS
                     $message = preg_replace('#<img(\\s[^<>]*?)>#i', '&lt;img$1&gt;', $message);
                     Page::header(array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => Guardian::happy() ? 1 : 2, 'Content Type' => $parser, 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false))->content($message)->saveTo(COMMENT . DS . $post . '_' . Date::slug($id) . '_' . ($parent ? Date::slug($parent) : '0000-00-00-00-00-00') . $extension);
                     Notify::success(Config::speak('notify_success_submitted', $speak->comment));
                     if ($extension === '.hold') {
                         Notify::info($speak->notify_info_comment_moderation);
                     }
                     Weapon::fire(array('on_comment_update', 'on_comment_construct'), array($G, $P));
                     Guardian::kick($config->url_current . $config->ur_query . (!Guardian::happy() && $config->comments->moderation ? '#' . $comment_form_id : '#' . sprintf($comment_id, Date::format($id, 'U'))));
                 } else {
                     Guardian::kick($config->url_current . $config->url_query . '#' . $comment_form_id);
                 }
             }
         }
     }
 }