Example #1
0
function Flgn_ready()
{
    try {
        global $Grot_path;
        Fcom_setLogInfo("debug", "login ready:" . $Grot_path);
        $map = Net_URL_Mapper::getInstance();
        $map->connect('/:app/:func/:type/:cont');
        $url = $map->match($Grot_path);
        if ($url) {
            if (0 !== strcmp($url["app"], DROT_APP_NAME) || 0 !== strcmp($url["func"], DROT_FUNC_FNC)) {
                Frot_jumpFirst();
            }
            if (0 === strcmp($url["type"], DROT_FTYPE_ATH)) {
                $ret = Fath_ctrl($url["cont"]);
                echo json_encode($ret);
                return;
            }
        } else {
            # Fcom_setLogInfo( DCOM_LOGLV_ERR , "".$Grot_path );
            Fapp_jumpFirst();
        }
    } catch (Exception $e) {
        throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '()' . PHP_EOL . $e->getMessage());
    }
}
Example #2
0
function Flgn_init()
{
    try {
        global $Grot_path;
        $map = Net_URL_Mapper::getInstance();
        $map->connect('/:app/:func/:type/:cont');
        $npurl = Frot_getNoprmPath($Grot_path);
        $url = $map->match($npurl);
        # Fcom_setLogInfo( "debug" , "Flgn_init:".$Grot_path );
        if ($url) {
            if (0 !== strcmp($url["app"], DROT_APP_NAME)) {
                Fcom_setLogInfo(DCOM_LOGLV_ERR, "invalid function " . $Grot_path);
                Fapp_jumpFirst();
            }
            if (0 === strcmp($url["func"], DROT_FUNC_SRC)) {
                Flgn_iniSrc($url);
            } else {
                Fcom_setLogInfo(DCOM_LOGLV_ERR, "invalid function " . $Grot_path);
                Fapp_jumpFirst();
            }
        } else {
            Frot_jumpFirst();
        }
    } catch (Exception $e) {
        throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '()' . PHP_EOL . $e->getMessage());
    }
}
Example #3
0
function Fapp_first()
{
    try {
        global $Grot_path;
        # Fcom_setLogInfo( "debug" , "app first:".$Grot_path );
        $map = Net_URL_Mapper::getInstance();
        $map->connect('/:app/');
        $url = $map->match($Grot_path);
        if ($url) {
            /* match */
            /* check func */
            if (0 === strcmp($url["app"], DROT_APP_NAME)) {
                /* '/ayawave' request */
                $cont = Frot_getInit(DROT_INITTYP_BSC);
                Frot_setSession(DROT_SESROT_SUBSTT, DROT_SUBSTT_INI, false);
                echo $cont;
                return;
            } else {
                /* func is not app */
                Fapp_jumpFirst();
            }
        } else {
            Fapp_jumpFirst();
        }
    } catch (Exception $e) {
        throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '()' . PHP_EOL . $e->getMessage());
    }
}
Example #4
0
function Fapp_ready()
{
    try {
        global $Grot_path;
        # Fcom_setLogInfo( "debug" , "Fapp_ready:".$Grot_path );
        $map = Net_URL_Mapper::getInstance();
        $map->connect('/:app/:func/:type/:cont');
        $url = $map->match($Grot_path);
        if ($url) {
            if (0 !== strcmp($url["app"], DROT_APP_NAME)) {
                Fcom_setLogInfo(DCOM_LOGLV_ERR, "invalid function " . $Grot_path);
                Fapp_jumpFirst();
            }
            if (0 === strcmp($url["func"], DROT_FUNC_SRC)) {
                Fapp_rdySrc($url);
            } else {
                if (0 === strcmp($url["func"], DROT_FUNC_FNC)) {
                    Fapp_rdyFunc($url);
                }
            }
        } else {
            $map->reset();
            $map->connect("/:app/:type");
            $url = $map->match($Grot_path);
            if ($url) {
                if (0 !== strcmp($url["app"], DROT_APP_NAME)) {
                    Fapp_jumpFirst();
                }
                if (0 === strcmp($url["type"], "item")) {
                    if (0 === strcmp($_GET["func"], "new")) {
                        echo Frot_getInit(DROT_INITTYP_NEW);
                    } else {
                        if (0 === strcmp($_GET["func"], "edit")) {
                            echo Frot_getInit(DROT_INITTYP_EDT);
                        }
                    }
                }
            } else {
                Fapp_jumpFirst();
            }
        }
    } catch (Exception $e) {
        throw new Exception('ERR(File:' . basename(__FILE__) . ',Line:' . __LINE__ . '):' . __FUNCTION__ . '()' . PHP_EOL . $e->getMessage());
    }
}
Example #5
0
 function initialize()
 {
     $m = Net_URL_Mapper::getInstance();
     // In the "root"
     $m->connect('', array('action' => 'public'));
     $m->connect('rss', array('action' => 'publicrss'));
     $m->connect('xrds', array('action' => 'publicxrds'));
     $m->connect('featuredrss', array('action' => 'featuredrss'));
     $m->connect('favoritedrss', array('action' => 'favoritedrss'));
     $m->connect('opensearch/people', array('action' => 'opensearch', 'type' => 'people'));
     $m->connect('opensearch/notice', array('action' => 'opensearch', 'type' => 'notice'));
     // docs
     $m->connect('doc/:title', array('action' => 'doc'));
     // facebook
     $m->connect('facebook', array('action' => 'facebookhome'));
     $m->connect('facebook/index.php', array('action' => 'facebookhome'));
     $m->connect('facebook/settings.php', array('action' => 'facebooksettings'));
     $m->connect('facebook/invite.php', array('action' => 'facebookinvite'));
     $m->connect('facebook/remove', array('action' => 'facebookremove'));
     // main stuff is repetitive
     $main = array('login', 'logout', 'register', 'subscribe', 'unsubscribe', 'confirmaddress', 'recoverpassword', 'invite', 'favor', 'disfavor', 'sup', 'block', 'subedit');
     foreach ($main as $a) {
         $m->connect('main/' . $a, array('action' => $a));
     }
     $m->connect('main/tagother/:id', array('action' => 'tagother'));
     // these take a code
     foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
         $m->connect('main/' . $c . '/:code', array('action' => $c));
     }
     // exceptional
     $m->connect('main/openid', array('action' => 'openidlogin'));
     $m->connect('main/remote', array('action' => 'remotesubscribe'));
     $m->connect('main/remote?nickname=:nickname', array('action' => 'remotesubscribe'), array('nickname' => '[A-Za-z0-9_-]+'));
     foreach (Router::$bare as $action) {
         $m->connect('index.php?action=' . $action, array('action' => $action));
     }
     // settings
     foreach (array('profile', 'avatar', 'password', 'openid', 'im', 'email', 'sms', 'twitter', 'other') as $s) {
         $m->connect('settings/' . $s, array('action' => $s . 'settings'));
     }
     // search
     foreach (array('group', 'people', 'notice') as $s) {
         $m->connect('search/' . $s, array('action' => $s . 'search'));
         $m->connect('search/' . $s . '?q=:q', array('action' => $s . 'search'), array('q' => '.+'));
     }
     $m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
     // notice
     $m->connect('notice/new', array('action' => 'newnotice'));
     $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), array('replyto' => '[A-Za-z0-9_-]+'));
     $m->connect('notice/:notice', array('action' => 'shownotice'), array('notice' => '[0-9]+'));
     $m->connect('notice/delete', array('action' => 'deletenotice'));
     $m->connect('notice/delete/:notice', array('action' => 'deletenotice'), array('notice' => '[0-9]+'));
     $m->connect('message/new', array('action' => 'newmessage'));
     $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]+'));
     $m->connect('message/:message', array('action' => 'showmessage'), array('message' => '[0-9]+'));
     $m->connect('user/:id', array('action' => 'userbyid'), array('id' => '[0-9]+'));
     $m->connect('tags/', array('action' => 'publictagcloud'));
     $m->connect('tag/', array('action' => 'publictagcloud'));
     $m->connect('tags', array('action' => 'publictagcloud'));
     $m->connect('tag', array('action' => 'publictagcloud'));
     $m->connect('tag/:tag/rss', array('action' => 'tagrss'), array('tag' => '[a-zA-Z0-9]+'));
     $m->connect('tag/:tag', array('action' => 'tag'), array('tag' => '[a-zA-Z0-9]+'));
     $m->connect('peopletag/:tag', array('action' => 'peopletag'), array('tag' => '[a-zA-Z0-9]+'));
     $m->connect('featured/', array('action' => 'featured'));
     $m->connect('featured', array('action' => 'featured'));
     $m->connect('favorited/', array('action' => 'favorited'));
     $m->connect('favorited', array('action' => 'favorited'));
     // groups
     $m->connect('group/new', array('action' => 'newgroup'));
     foreach (array('edit', 'join', 'leave') as $v) {
         $m->connect('group/:nickname/' . $v, array('action' => $v . 'group'), array('nickname' => '[a-zA-Z0-9]+'));
     }
     foreach (array('members', 'logo', 'rss') as $n) {
         $m->connect('group/:nickname/' . $n, array('action' => 'group' . $n), array('nickname' => '[a-zA-Z0-9]+'));
     }
     $m->connect('group/:id/id', array('action' => 'groupbyid'), array('id' => '[0-9]+'));
     $m->connect('group/:nickname', array('action' => 'showgroup'), array('nickname' => '[a-zA-Z0-9]+'));
     $m->connect('group/', array('action' => 'groups'));
     $m->connect('group', array('action' => 'groups'));
     $m->connect('groups/', array('action' => 'groups'));
     $m->connect('groups', array('action' => 'groups'));
     // Twitter-compatible API
     // statuses API
     $m->connect('api/statuses/:method', array('action' => 'api', 'apiaction' => 'statuses'), array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|friends|followers|featured)(\\.(atom|rss|xml|json))?'));
     $m->connect('api/statuses/:method/:argument', array('action' => 'api', 'apiaction' => 'statuses'), array('method' => '(user_timeline|friends_timeline|replies|show|destroy|friends|followers)'));
     // users
     $m->connect('api/users/:method/:argument', array('action' => 'api', 'apiaction' => 'users'), array('method' => 'show(\\.(xml|json))?'));
     $m->connect('api/users/:method', array('action' => 'api', 'apiaction' => 'users'), array('method' => 'show(\\.(xml|json))?'));
     // direct messages
     foreach (array('xml', 'json') as $e) {
         $m->connect('api/direct_messages/new.' . $e, array('action' => 'api', 'apiaction' => 'direct_messages', 'method' => 'create.' . $e));
     }
     foreach (array('xml', 'json', 'rss', 'atom') as $e) {
         $m->connect('api/direct_messages.' . $e, array('action' => 'api', 'apiaction' => 'direct_messages', 'method' => 'direct_messages.' . $e));
     }
     foreach (array('xml', 'json', 'rss', 'atom') as $e) {
         $m->connect('api/direct_messages/sent.' . $e, array('action' => 'api', 'apiaction' => 'direct_messages', 'method' => 'sent.' . $e));
     }
     $m->connect('api/direct_messages/destroy/:argument', array('action' => 'api', 'apiaction' => 'direct_messages'));
     // friendships
     $m->connect('api/friendships/:method/:argument', array('action' => 'api', 'apiaction' => 'friendships'), array('method' => '(create|destroy)'));
     $m->connect('api/friendships/:method', array('action' => 'api', 'apiaction' => 'friendships'), array('method' => 'exists(\\.(xml|json))'));
     // Social graph
     $m->connect('api/friends/ids/:argument', array('action' => 'api', 'apiaction' => 'statuses', 'method' => 'friendsIDs'));
     foreach (array('xml', 'json') as $e) {
         $m->connect('api/friends/ids.' . $e, array('action' => 'api', 'apiaction' => 'statuses', 'method' => 'friendsIDs.' . $e));
     }
     $m->connect('api/followers/ids/:argument', array('action' => 'api', 'apiaction' => 'statuses', 'method' => 'followersIDs'));
     foreach (array('xml', 'json') as $e) {
         $m->connect('api/followers/ids.' . $e, array('action' => 'api', 'apiaction' => 'statuses', 'method' => 'followersIDs.' . $e));
     }
     // account
     $m->connect('api/account/:method', array('action' => 'api', 'apiaction' => 'account'));
     // favorites
     $m->connect('api/favorites/:method/:argument', array('action' => 'api', 'apiaction' => 'favorites'));
     $m->connect('api/favorites/:argument', array('action' => 'api', 'apiaction' => 'favorites', 'method' => 'favorites'));
     foreach (array('xml', 'json', 'rss', 'atom') as $e) {
         $m->connect('api/favorites.' . $e, array('action' => 'api', 'apiaction' => 'favorites', 'method' => 'favorites.' . $e));
     }
     // notifications
     $m->connect('api/notifications/:method/:argument', array('action' => 'api', 'apiaction' => 'favorites'));
     // blocks
     $m->connect('api/blocks/:method/:argument', array('action' => 'api', 'apiaction' => 'blocks'));
     // help
     $m->connect('api/help/:method', array('action' => 'api', 'apiaction' => 'help'));
     // laconica
     $m->connect('api/laconica/:method', array('action' => 'api', 'apiaction' => 'laconica'));
     // search
     $m->connect('api/search.atom', array('action' => 'twitapisearchatom'));
     $m->connect('api/search.json', array('action' => 'twitapisearchjson'));
     $m->connect('api/trends.json', array('action' => 'twitapitrends'));
     // user stuff
     foreach (array('subscriptions', 'subscribers', 'nudge', 'xrds', 'all', 'foaf', 'replies', 'inbox', 'outbox', 'microsummary') as $a) {
         $m->connect(':nickname/' . $a, array('action' => $a), array('nickname' => '[a-zA-Z0-9]{1,64}'));
     }
     foreach (array('subscriptions', 'subscribers') as $a) {
         $m->connect(':nickname/' . $a . '/:tag', array('action' => $a), array('tag' => '[a-zA-Z0-9]+', 'nickname' => '[a-zA-Z0-9]{1,64}'));
     }
     foreach (array('rss', 'groups') as $a) {
         $m->connect(':nickname/' . $a, array('action' => 'user' . $a), array('nickname' => '[a-zA-Z0-9]{1,64}'));
     }
     foreach (array('all', 'replies', 'favorites') as $a) {
         $m->connect(':nickname/' . $a . '/rss', array('action' => $a . 'rss'), array('nickname' => '[a-zA-Z0-9]{1,64}'));
     }
     $m->connect(':nickname/favorites', array('action' => 'showfavorites'), array('nickname' => '[a-zA-Z0-9]{1,64}'));
     $m->connect(':nickname/avatar/:size', array('action' => 'avatarbynickname'), array('size' => '(original|96|48|24)', 'nickname' => '[a-zA-Z0-9]{1,64}'));
     $m->connect(':nickname', array('action' => 'showstream'), array('nickname' => '[a-zA-Z0-9]{1,64}'));
     Event::handle('RouterInitialized', array($m));
     return $m;
 }
Example #6
0
 /**
  * Try to match the HTTP method and path given with the routes saved.
  * If match returns an array with the method and the params matched.
  * 
  * @param string $httpMethod Http method
  * @param string $path       Path
  * 
  * @return array
  */
 public function match($httpMethod, $path)
 {
     $url = $this->url($httpMethod, $path);
     $match = Net_URL_Mapper::getInstance()->match($url);
     if (!$match) {
         return array(false, false);
     }
     $method = $match[self::MATCH_METHOD_PARAM];
     unset($match[self::MATCH_METHOD_PARAM]);
     return array($method, $match);
 }
Example #7
0
File: index.php Project: demental/m
<?php

/**
* M PHP Framework
* @package      M
*/
/**
* M PHP Framework
*
* Controller main file for default app
*
* @package      M
* @author       Arnaud Sellenet <demental at github>

* @license      http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
* @version      0.1
*/
define('APP_NAME', '{$APP_NAME}');
require '{$APP_RELATIVE_FILE_TO_ROOT}/M_Startup.php';
require APP_ROOT . 'app/' . APP_NAME . '/routing.php';
$result = Net_URL_Mapper::getInstance()->match($_GET['route']);
$getvalues = array_merge($result, $_GET);
$requestvalues = array_merge($_POST, $get);
$request = new MRequest($getvalues, $requestvalues);
$d = new Dispatcher($request);
$d->setConfig(PEAR::getStaticProperty('Dispatcher', 'global'));
$d->execute();
header('Content-type:text/html; charset=utf-8');
echo $d->display();
Example #8
0
File: URL.php Project: demental/m
 /**
  * generates and returns a relative path.
  * @param $route string module/action string
  * @param $params array associative array of additional parameters to include in the generated URL
  * @param $lang string specifies language for the generated url. If not provided uses the current language
  * @return string generated relative path
  **/
 public static function getAnchor($route, $params = null, $lang = null)
 {
     if (self::$method == 'old') {
         return self::getOldAnchor($route, $params, $lang);
     }
     unset($params['lang']);
     unset($params['module']);
     unset($params['action']);
     if ($lang == null) {
         $lang = T::getLang();
     }
     $params['lang'] = $lang;
     list($params['module'], $params['action']) = explode('/', $route);
     if (empty($params['action'])) {
         $params['action'] = null;
     }
     return Net_URL_Mapper::getInstance()->generate($params);
 }
Example #9
0
 public function testSharp()
 {
     $m = Net_URL_Mapper::getInstance();
     $m->reset();
     $m->connect('/account/:action/:handle*(section)', array('module' => 'account', 'section' => '#default'), array('handle' => '[a-zA-Z0-9]{3,12}', 'section' => '#\\w+'));
     $this->assertEquals('/account/edit/mansion#password', $m->generate(array('module' => 'account', 'action' => 'edit', 'handle' => 'mansion', 'section' => '#password')));
     $this->assertEquals('/account/edit/mansion#default', $m->generate(array('module' => 'account', 'action' => 'edit', 'handle' => 'mansion')));
 }
Example #10
0
 public function testDynamicWithRegexpGapsControllers2()
 {
     $m = Net_URL_Mapper::getInstance();
     $m->reset();
     $m->connect('view/:id/:controller', array('id' => '2', 'action' => 'view'), array('id' => '\\d{1,2}', 'controller' => '(blog|test)'));
     $this->assertEquals(null, $m->match('/view/4/honker'));
 }
 /**
  * Set router
  *
  * @access protected
  * @return Net_URL_Dispatcher Fluent interface
  */
 protected function _setRouter()
 {
     require_once 'Net/URL/Mapper.php';
     $this->_router = Net_URL_Mapper::getInstance($this->_mapperId);
     return $this;
 }