Beispiel #1
0
function smarty_function_url($params)
{
    if (isset($params['ignore'])) {
        return Swoole\Tool::url_merge($params['key'], $params['value'], $params['ignore']);
    } else {
        return Swoole\Tool::url_merge($params['key'], $params['value']);
    }
}
Beispiel #2
0
 function category()
 {
     if (empty($_GET['cid'])) {
         return "Access Deny";
     }
     //Error::dbd();
     $this->common();
     $tplname = strtolower($this->app) . '_list.html';
     $cate_id = (int) $_GET['cid'];
     $cate = getCategory($cate_id);
     if (empty($cate)) {
         Swoole_js::js_back('不存在的分类!', '/index.php');
         exit;
     }
     if (!empty($cate['uptime']) and Swoole\Tool::httpExpire($cate['uptime']) === false) {
         exit;
     }
     if ($cate['fid'] == 0) {
         $this->swoole->tpl->assign("fid", $cate_id);
         $this->swoole->tpl->assign("ccate", $cate);
         if ($cate['tplname']) {
             $tplname = $cate['tplname'];
         }
         $gets['fid'] = $cate_id;
     } else {
         if ($cate['tplname']) {
             $tplname = $cate['tplname'];
         }
         $this->swoole->tpl->assign("cate", $cate);
         $ccate = $this->swoole->db->query("select * from st_catelog where id={$cate['fid']} limit 1")->fetch();
         $this->swoole->tpl->assign("ccate", $ccate);
         $gets['cid'] = $cate_id;
     }
     $pager = null;
     $gets['order'] = 'addtime desc';
     $gets['page'] = empty($_GET['page']) ? 1 : (int) $_GET['page'];
     $gets['pagesize'] = empty($this->_model->pagesize) ? $this->swoole->config['cms']['pagesize'] : $this->_model->pagesize;
     $gets['select'] = "id,title,addtime";
     $list = $this->_model->gets($gets, $pager);
     if ($this->swoole->config['cms']['html_static']) {
         $pager->page_tpl = WEBROOT . "/{$this->app}/list_{$cate_id}_%s.html";
     }
     $pager = array('total' => $pager->total, 'render' => $pager->render());
     $this->swoole->tpl->assign('pager', $pager);
     $this->swoole->tpl->assign("list", $list);
     $this->swoole->tpl->assign('cid', $cate_id);
     $this->swoole->tpl->display($tplname);
 }
Beispiel #3
0
 function comment()
 {
     Swoole::$php->session->start();
     if (!$_SESSION['isLogin']) {
         return 'nologin';
     }
     $uid = $_SESSION['user_id'];
     $post['aid'] = (int) $_POST['aid'];
     $post['app'] = $_POST['app'];
     $post['content'] = $_POST['content'];
     $post['uid'] = $uid;
     $post['uname'] = $_SESSION['user']['nickname'];
     if ($post['app'] === 'mblog') {
         $m = createModel('MicroBlog');
         $entity = $m->get($post['aid']);
         $entity->reply_count++;
         $entity->save();
         if ($entity->uid != $uid) {
             App\Api::sendmail($entity->uid, $uid, "【系统】{$post['uname']}评论了你的微博", $post['content']);
         }
     } elseif ($post['app'] === 'blog') {
         $m = createModel('UserLogs');
         $entity = $m->get($post['aid']);
         $entity->reply_count++;
         $entity->save();
         if ($entity->uid != $uid) {
             App\Api::sendmail($entity->uid, $uid, "【系统】{$post['uname']}评论了你的日志.({$entity['title']})", $post['content']);
         }
     }
     createModel('UserComment')->put($post);
     $return = array('id' => $_SESSION['user']['id'], 'addtime' => Swoole\Tool::howLongAgo(date('Y-m-d H:i:s')), 'nickname' => $_SESSION['user']['nickname']);
     if (empty($_SESSION['user']['avatar'])) {
         $return['avatar'] = Swoole::$php->config['user']['default_avatar'];
     } else {
         $return['avatar'] = $_SESSION['user']['avatar'];
     }
     return $return;
 }
Beispiel #4
0
function swoole_urlrouter_mvc(&$uri)
{
    $array = array('controller' => 'page', 'view' => 'index');
    if (!empty($_GET["c"])) {
        $array['controller'] = $_GET["c"];
    }
    if (!empty($_GET["v"])) {
        $array['view'] = $_GET["v"];
    }
    if (empty($uri) or substr($uri, -8) == 'index.php') {
        return $array;
    }
    $request = explode('/', $uri, 3);
    if (count($request) < 2) {
        return $array;
    }
    $array['controller'] = $request[0];
    $array['view'] = $request[1];
    if (isset($request[2])) {
        $request[2] = trim($request[2], '/');
        $_id = str_replace('.html', '', $request[2]);
        if (is_numeric($_id)) {
            $_GET['id'] = $_id;
        } else {
            Swoole\Tool::$url_key_join = '-';
            Swoole\Tool::$url_param_join = '-';
            Swoole\Tool::$url_add_end = '.html';
            Swoole\Tool::$url_prefix = WEBROOT . "/{$request[0]}/{$request['1']}/";
            Swoole\Tool::url_parse_into($request[2], $_GET);
        }
    }
    return $array;
}
Beispiel #5
0
function url_process_default()
{
    $array = array('controller' => 'page', 'view' => 'index');
    if (!empty($_GET["c"])) {
        $array['controller'] = $_GET["c"];
    }
    if (!empty($_GET["v"])) {
        $array['view'] = $_GET["v"];
    }
    $uri = parse_url($_SERVER['REQUEST_URI']);
    if (empty($uri['path']) or $uri['path'] == '/' or $uri['path'] == '/index.php') {
        return $array;
    }
    $request = explode('/', trim($uri['path'], '/'), 3);
    if (count($request) < 2) {
        return $array;
    }
    $array['controller'] = $request[0];
    $array['view'] = $request[1];
    if (is_numeric($request[2])) {
        $_GET['id'] = $request[2];
    } else {
        Swoole\Tool::$url_key_join = '-';
        Swoole\Tool::$url_param_join = '-';
        Swoole\Tool::$url_add_end = '.html';
        Swoole\Tool::$url_prefix = "/{$request[0]}/{$request['1']}/";
        Swoole\Tool::url_parse_into($request[2], $_GET);
    }
    return $array;
}
function smarty_modifier_howLongAgo($string)
{
    return Swoole\Tool::howLongAgo($string);
}
Beispiel #7
0
function swoole_urlrouter_mvc(&$uri)
{
    $array = Swoole::$default_controller;
    if (!empty($_GET["c"])) {
        $array['controller'] = $_GET["c"];
    }
    if (!empty($_GET["v"])) {
        $array['view'] = $_GET["v"];
    }
    $request = explode('/', $uri, 3);
    if (count($request) < 2) {
        return $array;
    }
    $array['controller'] = $request[0];
    $array['view'] = $request[1];
    if (isset($request[2])) {
        $request[2] = trim($request[2], '/');
        $_id = str_replace('.html', '', $request[2]);
        if (is_numeric($_id)) {
            $_GET['id'] = $_id;
        } else {
            Swoole\Tool::$url_key_join = '-';
            Swoole\Tool::$url_param_join = '-';
            Swoole\Tool::$url_add_end = '.html';
            Swoole\Tool::$url_prefix = WEBROOT . "/{$request[0]}/{$request['1']}/";
            Swoole\Tool::url_parse_into($request[2], $_GET);
        }
        $_REQUEST = array_merge($_REQUEST, $_GET);
    }
    return $array;
}
Beispiel #8
0
 private function __construct()
 {
     if (!defined('DEBUG')) {
         define('DEBUG', 'off');
     }
     if (DEBUG == 'off') {
         \error_reporting(0);
     }
     #初始化App环境
     //为了兼容老的APPSPATH预定义常量方式
     if (defined('APPSPATH')) {
         self::$app_root = str_replace(WEBPATH, '', APPSPATH);
     } elseif (empty(self::$app_root)) {
         self::$app_root = "/apps";
     }
     self::$app_path = WEBPATH . self::$app_root;
     $this->env['app_root'] = self::$app_root;
     //        $this->__init();
     $this->load = new Swoole\Loader($this);
     $this->model = new Swoole\ModelLoader($this);
     $this->plugin = new Swoole\PluginLoader($this);
     //路由钩子,URLRewrite
     $this->addHook(Swoole::HOOK_ROUTE, function (&$uri) {
         $rewrite = Swoole::$php->config['rewrite'];
         if (empty($rewrite) or !is_array($rewrite)) {
             return false;
         }
         $match = array();
         foreach ($rewrite as $rule) {
             if (preg_match('#' . $rule['regx'] . '#', $uri['path'], $match)) {
                 //合并到GET中
                 if (isset($rule['get'])) {
                     $p = explode(',', $rule['get']);
                     foreach ($p as $k => $v) {
                         $_GET[$v] = $match[$k + 1];
                     }
                 }
                 return $rule['mvc'];
             }
         }
         return false;
     });
     //mvc
     $this->addHook(Swoole::HOOK_ROUTE, function (&$uri) {
         $array = array('controller' => 'page', 'view' => 'index');
         if (!empty($_GET["c"])) {
             $array['controller'] = $_GET["c"];
         }
         if (!empty($_GET["v"])) {
             $array['view'] = $_GET["v"];
         }
         if (empty($uri['path']) or $uri['path'] == '/' or $uri['path'] == '/index.php') {
             return $array;
         }
         $request = explode('/', trim($uri['path'], '/'), 3);
         if (count($request) < 2) {
             return $array;
         }
         $array['controller'] = $request[0];
         $array['view'] = $request[1];
         if (isset($request[2])) {
             $request[2] = trim($request[2], '/');
             if (is_numeric($request[2])) {
                 $_GET['id'] = $request[2];
             } else {
                 Swoole\Tool::$url_key_join = '-';
                 Swoole\Tool::$url_param_join = '-';
                 Swoole\Tool::$url_add_end = '.html';
                 Swoole\Tool::$url_prefix = WEBROOT . "/{$request[0]}/{$request['1']}/";
                 Swoole\Tool::url_parse_into($request[2], $_GET);
             }
         }
         return $array;
     });
 }
Beispiel #9
0
}
?>
>
                                        <a href="<?php 
echo Swoole\Tool::url_merge('order', 'id_asc');
?>
">时间升序</a>
                                    </li>
                                    <li <?php 
if (empty($_GET['order']) or $_GET['order'] == 'id_desc') {
    echo 'class="active"';
}
?>
>
                                        <a href="<?php 
echo Swoole\Tool::url_merge('order', 'id_desc');
?>
">时间降序</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </header>
                    <div role="content">

                        <div class="jarviswidget-editbox">

                        </div>

                        <div class="widget-body no-padding">
                            <div class="widget-body-toolbar" style="height: 60px;">