Ejemplo n.º 1
0
<?php

include_model('forum_post');
helper('avatar');
verify_method('post', array('only', 'create, destroy, update, stick, unstick, lock, unlock'));
before_filter(array('only_user' => 40), 'only', 'stick, unstick, lock, unlock');
before_filter(array('only_user' => 10), 'only', 'destroy, update, edit, add, mark_all_read');
before_filter(array('post_only_user' => 10), 'only', 'create');
set_actions('stick', 'unstick', 'preview', 'new', 'create', 'destroy', 'edit', 'update', 'show', 'index', 'search', 'lock', 'unlock', 'mark_all_read');
Ejemplo n.º 2
0
<?php

verify_method('post', array('only', 'create, destroy, update, mark_as_spam'));
before_filter(array('only_user' => 20), 'only', 'create, destroy, update');
before_filter(array('only_user' => 33), 'only', 'moderate');
helper('post', 'avatar');
set_actions('index', 'create', 'edit', 'update', 'destroy', 'show');
Ejemplo n.º 3
0
 */
// load data model if these model methods are triggered
before_filter('load_model', 'delete_from_request');
before_filter('load_model', 'insert_from_request');
before_filter('load_model', 'update_from_request');
before_filter('load_model', 'fields_from_request');
before_filter('load_model', 'MoveFirst');
before_filter('load_model', 'MoveNext');
before_filter('load_model', 'base');
before_filter('load_model', 'find');
// add a filter to persist submitted data on error
before_filter('session_error', 'handle_error');
// activate Taint Mode to validate each input
before_filter('regex_validate', 'save_record');
// read the Access List and verify action permissions
before_filter('model_security', $request->action);
// if public resource, ping the search index server
after_filter('send_ping', 'insert_from_post');
after_filter('send_ping', 'update_from_post');
// echo value after single-field Ajax PUT call
after_filter('ajax_put_field', 'update_from_post');
after_filter('ajax_put_field', 'insert_from_post');
// authenticate yourself without OpenID
//test_log_in();
function test_log_in()
{
    $person_id = 1;
    set_cookie($person_id);
    $_SESSION['openid_complete'] = true;
}
/**
Ejemplo n.º 4
0
<?php

before_filter('redirect_homepage');
layout('bare');
set_actions('index');
Ejemplo n.º 5
0
<?php

before_filter('resize_uploaded_image', 'pre_insert');
before_filter('resize_uploaded_image', 'pre_update');
function resize_uploaded_image(&$rec, &$db)
{
    // this happens before validate_identities_photo
    if (!is_upload('identities', 'photo')) {
        return;
    }
    $size = filesize($_FILES['identity']['tmp_name']['photo']);
    if (!$size || $size > 409600) {
        if (file_exists($_FILES['identity']['tmp_name']['photo'])) {
            unlink($_FILES['identity']['tmp_name']['photo']);
        }
        trigger_error("That photo is too big. Please find one that is smaller than 400K.", E_USER_ERROR);
    }
    $upl = $_FILES['identity']['tmp_name']['photo'];
    $ext = '.' . type_of_image($upl);
    if (!$ext) {
        trigger_error("Sorry for the trouble, but your photo must be a JPG, PNG or GIF file.", E_USER_ERROR);
    }
    $orig = $_FILES['identity']['tmp_name']['photo'];
    $newthumb = tempnam("/tmp", "new" . $rec->id . $ext);
    photoCreateCropThumb($newthumb, $orig, 96, 100, $upl);
    $rec->attributes['photo'] = $newthumb;
}
function validate_identities_url($value)
{
    if ($value == 'http://') {
        return true;
Ejemplo n.º 6
0
<?php

verify_method('post', array('only', 'authenticate', 'update', 'create', 'unban', 'modify_blacklist', 'check'));
before_filter(array('only_user' => 10), 'only', 'authenticate, update, edit, modify_blacklist');
before_filter(array('only_user' => 35), 'only', 'invites');
before_filter(array('only_user' => 40), 'only', 'block, unblock, show_blocked_users');
before_filter(array('post_only_user' => 20), 'only', 'set_avatar');
// filter_parameter_logging :password
// auto_complete_for :user, :name
helper('avatar');
set_actions('authenticate', 'change_password', 'check', 'create', 'edit', 'home', 'login', 'logout', 'modify_blacklist', 'set_avatar', 'show', 'signup', 'update');
Ejemplo n.º 7
0
<?php

before_filter(array('only_user' => 20), 'only', 'create, destroy, delete, flag, revert_tags, activate, update_batch');
before_filter(array('post_only_user' => 20), 'only', 'update, upload, flag');
before_filter(array('only_user' => 33), 'only', 'moderate, undelete');
before_filter(array('only_user' => 50), 'only', 'import, export');
verify_method('post', array('only', 'update, destroy, create, revert_tags, vote, flag'));
after_filter('save_tags_to_cookie', 'only', 'update, create');
helper('avatar', 'tag', 'comment', 'pool', 'favorite');
set_actions('activate', 'browse', 'create', 'delete', 'destroy', 'error', 'flag', 'index', 'import', 'moderate', 'random', 'show', 'undelete', 'update', 'update_batch', 'upload', 'vote');
Ejemplo n.º 8
0
function app_init($appname)
{
    $startfile = app_path() . $appname . DIRECTORY_SEPARATOR . $appname . ".php";
    if (is_file($startfile)) {
        require_once $startfile;
    }
    $pluginsdir = app_path() . $appname . DIRECTORY_SEPARATOR . 'plugins';
    if (is_dir($pluginsdir)) {
        $GLOBALS['PATH']['app_plugins'][] = $pluginsdir;
        $startfile = $pluginsdir . DIRECTORY_SEPARATOR . $appname . ".php";
        if (is_file($startfile)) {
            require_once $startfile;
        }
    }
    $events = array('admin_head' => 'head', 'admin_menu' => 'menu', 'wp_head' => 'head', 'publish_post' => 'post', 'the_content' => 'show');
    foreach ($events as $wpevent => $dbevent) {
        if (function_exists($appname . '_' . $dbevent)) {
            add_action($wpevent, $appname . '_' . $dbevent);
        }
    }
    if (function_exists($appname . "_init")) {
        before_filter($appname . "_init", 'init');
    }
}
Ejemplo n.º 9
0
<?php

before_filter(array('only_user' => 20), 'only', 'create');
verify_method('post', array('only', 'create', 'update'));
set_actions('index', 'update', 'create');
Ejemplo n.º 10
0
<?php

// layout 'default', :only => [:index, :history, :search]
before_filter(array('post_only_user' => 20), 'only', 'destroy, update, revert');
verify_method('post', array('only', 'update, revert, destroy'));
set_actions('index', 'search', 'update');
Ejemplo n.º 11
0
<?php

before_filter(array('only_user' => 50), 'only', 'fix_count');
before_filter(array('only_user' => 40), 'only', 'mass_edit, edit_preview');
before_filter(array('only_user' => 20), 'only', 'update,  edit');
if (CONFIG::allow_delete_tags) {
    before_filter(array('only_user' => 35), 'only', 'delete');
}
set_actions('summary', 'index', 'fix_count', 'edit', 'update', 'related', CONFIG::allow_delete_tags && 'delete');
Ejemplo n.º 12
0
<?php

// do shortener redirect
// and set memcached 301
before_filter('do_shorten_redirect', 'find_by');
class Shortener extends Model
{
    function Shortener()
    {
        $this->char_field('apikey');
        $this->char_field('nickname');
        $this->char_field('password');
        $this->char_field('type');
        $this->int_field('urlcount');
        $this->int_field('hitcount');
        $this->char_field('urlbase');
        $this->char_field('endpoint');
        $this->time_field('created');
        $this->time_field('modified');
        $this->int_field('profile_id');
        $this->int_field('entry_id');
        $this->auto_field('id');
        // relationships
        $this->has_one('entry');
        // permissions
        $this->let_access('all:administrators');
    }
}
function get_code($seed_length = 30)
{
    $seed = "ABCDEFGHJKLMNPQRSTUVWXYZ234567892345678923456789";
Ejemplo n.º 13
0
    } else {
        // the nickname did not match a local user
        // check for the nickname at twitter.com
        $url = "http://twitter.com/" . $nick;
        require_once ABSPATH . WPINC . '/class-snoopy.php';
        $snoop = new Snoopy();
        $snoop->agent = 'OpenMicroBlogger http://openmicroblogger.org';
        $snoop->submit($url);
        if (strpos($snoop->response_code, '200')) {
            redirect_to($url);
        } else {
            trigger_error('sorry the nickname was not found on this site, nor at Twitter.com', E_USER_ERROR);
        }
    }
}
before_filter('omb_request_munger', 'routematch');
function omb_request_munger(&$request, &$route)
{
    global $omb_routes;
    // look for a dbscript omb Route in the POST/GET params
    $params = array_merge($_GET, $_POST);
    foreach ($omb_routes as $func) {
        if (array_key_exists($func, $params)) {
            // if found, lie to the mapper about the URI
            if (pretty_urls()) {
                $request->set('uri', $request->base . "" . $func);
            } else {
                $request->set('uri', $request->base . "?" . $func);
            }
            $request->set('params', array($func));
        }