Exemplo n.º 1
0
 public static function twitter($user, $max = self::DEFAULT_MAX, $template = false)
 {
     if (function_exists("include_gobe_module")) {
         include_gobe_module("output.format");
     }
     $template = self::getTemplate($template, "twitter");
     $source = @simplexml_load_file("http://twitter.com/statuses/user_timeline/{$user}.rss");
     if ($source === false || $template === false) {
         return self::DEFAULT_ERROR;
     }
     $response = "";
     $count = 0;
     $frontTrim = strlen($user) + 2;
     foreach ($source->channel->item as $entry) {
         $response .= self::format($template, array("url" => $entry->link, "date" => array($entry->pubDate, "fieldFormaterDate"), "body" => array(substr($entry->description, $frontTrim), "fieldFormaterLinks")));
         if ($max && ++$count == $max) {
             break;
         }
     }
     return $response;
 }
Exemplo n.º 2
0
<?php

/**
 * @abstract Ajax helpers. 
 * 
 * @author Justin Johnson <johnsonj>
 * @version 1.0.0 20080415 JJ
 * @version 0.0.1 20070306 JJ
 * 
 * @package zk.modules.ajax
 */
include_gobe_module('utils');
/**
 * @abstract An Ajax service helper.  Ajax::response should be used to handle all Ajax responses.
 * @uses Utils::array2xml Defined in Utils.
 */
class Ajax
{
    const XML = 1;
    const JSON = 2;
    const PLAIN = 3;
    const DEBUG = 4;
    /**
     * @abstract Creates a standard response the can be formatted into Json, Xml, plain 
     * text or 'debug' using var_export.
     * @param bool $status The status of the Ajax service response.
     * @param mixed $message  Optional. A message pertaining to the execution of the Ajax service 
     * from whence this method is called (default: '').  Can be empty.  Can be anything, really.
     * @param array $additionItems Optional.  Additional reponse data can be passed here (default: false).
     * @param flag $format The format in which to return the response as indicated by the const values in 
     * this class (Ajax::JSON, Ajax::XML, Ajax::PLAIN, and Ajax::DEBUG) (default: Ajax::JSON). If invalid,
Exemplo n.º 3
0
/**
 * @abstract HTML Page functionality
 * 
 * @author Justin Johnson <johnsonj>
 * @author Andrew Muprhy <*****@*****.**>
 * @version 20080430 JJ
 * @version 20080428 JJ
 * @version 20080427 JJ
 * @version 20080421 JJ
 * @version 20070701 AM
 * 
 * @package zk.modules.web.html
 */
include_gobe_module('builder.html');
include_gobe_module('builder.list');
class WebPage
{
    const TMPL_INC_CSS = "<link rel=\"stylesheet\" type=\"text/css\" media=\"%s\" title=\"%s\" href=\"%s\">\n";
    const TMPL_INC_CSS_IF = "<!--[if %s]>\n\t%s<![endif]-->\n";
    const TMPL_INC_JAVASCRIPT = "<script type=\"text/javascript\" src=\"%s\"></script>\n";
    const TMPL_INC_META = "<meta %s=\"%s\" content=\"%s\" />\n";
    private static $pageTitle;
    private static $relList;
    public function __construct()
    {
        self::$pageTitle = '';
        self::$relList = array();
    }
    /**
     * @abstract Gets the site's main title.
Exemplo n.º 4
0
<?php

include_gobe_module("goat");
/**
 * @abstract Generic web anayltics insertion
 * 
 * @author Justin Johnson <johnsonj>
 * @version 20090726 <johnsonj>
 * 
 * @package zk.modules.web.analytics
 */
class Analytics
{
    const TEMPLATE_EXTENSION = ".html";
    const TEMPLATE_PATH = "web/analytics/";
    const DEFAULT_TEMPLATE = "google";
    private static $blockedServers = array();
    private static $blockedUsers = array();
    public static function build($template, $id)
    {
        $template = self::getTemplate($template);
        return self::isBlocked() ? self::format($template, $id) : "";
    }
    public static function blockServer($domains)
    {
        self::$blockedServers = array_merge(self::$blockedServers, (array) $domains);
    }
    public static function blockUser($ips)
    {
        self::$blockedUsers = array_merge(self::$blockedUsers, (array) $ips);
    }
Exemplo n.º 5
0
<?php

/**
 * @abstract Centralized list handling.
 * 
 * @author Justin Johnson <johnsonj>
 * @version 0.5.1 20080428 JJ
 * @version 0.4.0 20080427 JJ
 * @version 0.1.0 20080421 JJ
 * 
 * @package zk.modules.builder.list
 */
include_gobe_module('builder.interface');
class ListBuilder implements Builder_static
{
    /**
     * @abatract Adds an item to a list.
     * 
     * @param mixed $listID The ID of the list to use.
     * @param mixed $data The data to add to the list.
     * @param mixed $index Optional. An exact index to insert $data at (default: null). If null, $data is prepended to the list.
     * 
     * @return bool Always returns true.
     */
    public static function add($listID, $data, $index = null)
    {
        return ListBuilder::handle($listID, HANDLE_ADD, $data, $index);
    }
    /**
     * @abatract Removes a list or an item from a list.
     * 
Exemplo n.º 6
0
<?php

/**
 * @abstract Email containers and functionality.
 * 
 * @author Justin Johnson <johnsonj>
 * @version 1.2.0 20090304 JJ (integrated PHP mailer)
 * @version 1.2.0 20080421 JJ
 * @version 1.0.0 20080416 JJ
 * 
 * @package zk.modules.email
 */
include_gobe_module('validate');
include_gobe_module('stdlib');
include_gobe_module('phpmailer.phpmailer');
/**
 * @absrtact Basic emailing functionality
 */
class Email
{
    /**
     * @abstract A wrapper to the mail function.  All parameters are the same accept for $headers.  The $to address will be validated
     * via Email::validate.
     *
     * @param mixed $to An email address which to send this email to.  Can either be a string address or an EmailAddress object.
     * @param string $subject The subject of the email.
     * @param string $message The message of the email.
     * @param mixed $headers Optional. If a string, then it is passed directly to mail() as it is; otherwise, it is passed to Email::headers()
     * (default: false).
     * @return bool True if the mail was sent successfully; otherwise, false.
     * 
Exemplo n.º 7
0
<?php

/**
 * @abstract Error handling procedures
 *
 * @author Justin Johnson <johnsonj>
 *
 * @version 1.0.1 20080312 JJ
 *
 * @package zk.modules.output.error
 */
//TODO: OO
include_gobe_module('output.multiform');
/**
 * Formats error strings into an error group container as deteremined by mode
 * @param array/string error The error strings to format
 * @param string mode Either 'text' or 'html'; defaults to 'html'
 * @return string Returns formatted errors in an error group container
 */
function error_compile($errors, $mode = "html")
{
    // Default to html mode for output
    if ($mode != "html" || $mode != "text") {
        $mode = "html";
    }
    // Always handle as an array
    if (!is_array($errors)) {
        $errors = array($errors);
    }
    // Get necessary templates
    $forms = multiform(PATH_TEMPLATES_STUBS . "errors.gform.html");
Exemplo n.º 8
0
<?php

/**
 * Examples listing adapted from HLocator
 *
 * @author Justin Johnson <johnsonj>, justin@zebrakick.com
 * @version 1.4.0 20080430 JJ
 * @version 1.2.0 20080317 JJ
 * @version 1.1.0 20080315 JJ
 * @version 1.0.0 20080314 JJ
 *
 */
include_gobe_module('output.multiform');
include_gobe_module('gallery.main');
include_gobe_module('gallery.results');
$countPerPage = isset($_GET['count']) && (int) $_GET['count'] > 0 ? (int) $_GET['count'] : DB_DEFAULT_LIMIT;
$currentPage = isset($_GET['page']) && (int) $_GET['page'] > 1 ? (int) $_GET['page'] : 1;
$startListing = ($currentPage - 1) * $countPerPage;
$sortBy = isset($_GET['sortBy']) ? $_GET['sortBy'] : 'high-low';
$templates = multiform(PATH_TEMPLATES . 'stubs/examples/sidebar.gform.html');
$results = getExamples();
if (!empty($results)) {
    $resultsList = $title = '';
    $goat = new goat();
    $goat->register_variable('title', '');
    $goat->register_variable('url', '');
    $goat->register_variable('alt', '');
    foreach ($results as $listing) {
        $title = stripslashes($listing['title']);
        $goat->mod_variable('title', $title);
        $goat->mod_variable('url', get_path('examples-details', true) . '?id=' . $listing['listing_id']);
Exemplo n.º 9
0
<?php

/**
 * @abstract Cryptography library
 * 
 * @author Justin Johnson <johnsonj>
 * @version 0.3.0 20080418 JJ
 * @version 0.2.0 20080411 JJ
 * @version 0.1.0 20080319 JJ
 * 
 * @package zk.modules.crypt.aes
 */
include_gobe_module('crypt.interface');
/* Adapted from code by "mre (at) reinhardt (dot) info" found at 
 * <http://php.net/mcrypt>
 */
class Aes128 implements cryptTemplate_static
{
    const DEFAULT_SALT = 'salt123@#$';
    /**
     * @abstract Encrypts a plain-text string with AES 128 bit. 
     *
     * @param string $text The string to encrypt.
     * @param string $salt Optional. A string to salt the encryption with (default: Aes128::DEFAULT_SALT).
     * @param string $iv Optional. A 16 character initialization vector (default: false).  If not provided (i.e.: false), a random 
     * IV will be generated.
     * @param bool $returnHex Optional.  Whether to return hex encoded string (true) or a binary string (false) (default: true).
     * @return string the encrypted string
     */
    public static function encrypt($text, $salt = Aes128::DEFAULT_SALT, $iv = false, $returnHex = true)
    {
Exemplo n.º 10
0
<?php

include_gobe_module("web.analytics");
set_path('home', SITE_BASEURL);
set_path('images', PATH_IMAGES);
set_path('css', PATH_CSS);
set_path('javascript', PATH_JAVASCRIPT);
/* Globally available variables */
add_gobe_variable('site-protocol', SITE_PROTOCOL);
Analytics::blockServer("dev." . DOMAIN_WEB);
Analytics::blockServer("127.0.0.1");
Analytics::blockUser("127.0.0.1");
Exemplo n.º 11
0
<?php

include_gobe_module("web.aggregate");