Ejemplo n.º 1
0
 public static function useIcon($id, array $attrs = array(), $path = "images/icons.svg")
 {
     static $url = null;
     if (is_null($url)) {
         $url = clone \shgysk8zer0\Core\URL::getInstance();
         unset($url->query, $url->user, $url->pass, $url->fragment);
     }
     $url->path = $path;
     $url->fragment = $id;
     $attrs['xmlns:xlink'] = self::USE_NS;
     $svg = new self($attrs);
     $use = $svg->documentElement->appendChild($svg->createElement('use'));
     $use->{'xlink:href'} = $url;
     return $svg->documentElement;
 }
Ejemplo n.º 2
0
function loadHead()
{
    $dom = \shgysk8zer0\DOM\HTML::getInstance();
    $url = \shgysk8zer0\Core\URL::getInstance();
    unset($url->path, $url->query, $url->fragment, $url->user, $url->pass);
    $frag = $dom->createDocumentFragment();
    $frag('title', 'Ad Insertion');
    $frag('link', null, ['rel' => 'icon', 'href' => 'favicon.svg', 'type' => 'image/svg+xml', 'sizes' => 'any']);
    $frag('link', null, ['rel' => 'stylesheet', 'href' => 'stylesheets/styles/styles.css', 'media' => 'all']);
    $frag('link', null, ['rel' => 'prefetch', 'href' => 'images/icons.svg', 'type' => 'image/svg+xml']);
    $frag('base', null, ['href' => $url]);
    $frag('script', null, ['type' => 'application/javascript', 'src' => 'scripts/custom.js', 'defer' => true]);
    $frag('meta', null, ['name' => 'description', 'content' => 'An ad insertion form for the Kern Valley Sun']);
    return $frag;
}
Ejemplo n.º 3
0
function buildForm()
{
    $form = \shgysk8zer0\DOM\HTML::getInstance()->createElement('form');
    $form->name = basename(__FILE__, '.php');
    $form->method = 'POST';
    $form->action = \shgysk8zer0\Core\URL::getInstance();
    $form->append('label', 'Email', ['for' => "{$form->name}[user]"]);
    $form->append('input', null, ['type' => 'email', 'name' => "{$form->name}[user]", 'id' => "{$form->name}[user]", 'placeholder' => '*****@*****.**', 'required' => '']);
    $form->append('br');
    $form->append('label', 'Password', ['for' => "{$form->name}[password]"]);
    $form->append('input', null, ['type' => 'password', 'name' => "{$form->name}[password]", 'id' => "{$form->name}[password]", 'placeholder' => '************', 'required' => '']);
    $form->append('hr');
    $form->append('button', null, ['type' => 'submit', 'title' => 'Submit'])->import(\shgysk8zer0\DOM\SVG::useIcon('check', ['height' => 30, 'width' => 30]));
    $form->append('button', null, ['type' => 'reset', 'title' => 'Reset'])->import(\shgysk8zer0\DOM\SVG::useIcon('x', ['height' => 30, 'width' => 30]));
    return $form;
}
Ejemplo n.º 4
0
/**
 * Updates feed.rss with the $lim most recent posts
 *
 * @param  int     $lim   Max number to include
 * @param  string  $name  Name of file output
 * @return void
 */
function update_rss($lim = 10, $name = 'feed.rss')
{
    if (!is_int($lim)) {
        $lim = 10;
    }
    $pdo = \shgysk8zer0\Core\PDO::load('connect');
    if ($pdo->connected) {
        $url = \shgysk8zer0\Core\URL::load(URL);
        $rss = new \shgysk8zer0\DOM\XML('rss', null, '1.0', 'UTF-8');
        $head = $pdo->nameValue('head');
        $posts = $pdo->fetchArray("SELECT `title`, `url`, `description`, `created`\n\t\t\tFROM `posts`\n\t\t\tWHERE `url` != ''\n\t\t\tORDER BY `created` DESC\n\t\t\tLIMIT {$lim};");
        $posts = new \shgysk8zer0\Core\ArrayObject($posts);
        $rss->documentElement->version = '2.0';
        $channel = $rss->documentElement->append('channel');
        $site = array('title' => htmlspecialchars($head->title, ENT_XML1, $rss->encoding), 'description' => htmlspecialchars($head->description, ENT_XML1, $rss->encoding), 'link' => URL, 'lastBuildDate' => date(DATE_RSS), 'laneguage' => 'en-us');
        array_map([$channel, 'append'], array_keys($site), array_values($site));
        $posts->reduce(function (\DOMElement $feed, \stdClass $post) use($url) {
            $item = $feed->append('item');
            $item->append('title', htmlspecialchars($post->title, ENT_XML1, $feed->ownerDocument->encoding));
            $item->append('link', "{$url}posts/{$post->url}");
            $item->append('description', htmlspecialchars($post->description, ENT_XML1, $feed->ownerDocument->encoding));
            $item->append('pubDate', date(DATE_RSS, strtotime($post->created)));
            $item->append('guid', "{$url}posts/{$post->url}");
            return $feed;
        }, $rss->documentElement);
        $rss->save(BASE . DIRECTORY_SEPARATOR . $name);
    }
}
Ejemplo n.º 5
0
    header('Content-Type: text/plain');
    http_response_code(500);
    exit('PHP version ' . getenv('MIN_PHP_VERSION') . ' or greater is required');
}
define('BASE', __DIR__);
if (PHP_SAPI === 'cli') {
    require_once __DIR__ . DIRECTORY_SEPARATOR . 'std-php-functions' . DIRECTORY_SEPARATOR . 'autoloader.php';
}
init();
if (!defined('THEME')) {
    define('THEME', 'default-theme');
}
define_UA();
set_exception_handler(new \shgysk8zer0\Core\ExceptionLog());
$redirect = false;
$URL = \shgysk8zer0\Core\URL::load();
$headers = \shgysk8zer0\Core\Headers::load();
if ($URL->host === 'localhost' and BROWSER === 'Chrome') {
    $URL->host = '127.0.0.1';
    $redirect = true;
} elseif (substr($URL->host, 0, 4) === 'www.') {
    $URL->host = substr($URL->host, 4);
    $redirect = true;
} elseif (array_key_exists('tags', $_REQUEST)) {
    $URL->path .= 'tags/' . urlencode($_REQUEST['tags']);
    $redirect = true;
}
if ($redirect) {
    unset($URL->user, $URL->pass, $URL->query, $URL->fragment);
    http_response_code(301);
    $headers->Location = "{$URL}";