rabin 1 سال پیش
والد
کامیت
9b6d389072
4فایلهای تغییر یافته به همراه111 افزوده شده و 18 حذف شده
  1. 78 0
      database/host.php
  2. 25 0
      database/info.php
  3. 0 11
      database/type.php
  4. 8 7
      lib/Handle.php

+ 78 - 0
database/host.php

@@ -0,0 +1,78 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'host',
+    # 显示给用户看的名称
+    'lang' => '域名管理',
+    # 是否显示在后台菜单
+    'order' => -1,
+
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'order'     => 'asc',
+            'list'      => true,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '域名',
+            'default'   => '',
+            'desc'      => '域名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+        
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+    ),
+
+    'default' => array
+    (
+        'col' => 'id, name,state,cdate',
+        'value' => array
+        (
+            '1, "http://u.buykey.cn/",1,' . DEVER_TIME,
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    )
+);

+ 25 - 0
database/info.php

@@ -12,6 +12,18 @@ $type = function()
     return $array;
 };
 
+$host = function()
+{
+    $array = array();
+    $info = Dever::db('short/host')->state();
+    
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
 return array
 (
     # 表名
@@ -36,6 +48,19 @@ return array
             'list'      => true,
         ),
 
+        'host_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '域名',
+            'default'   => '1',
+            'desc'      => '域名',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $host,
+            'search'    => 'select',
+            'list'        => true,
+        ),
+
         'type_id'       => array
         (
             'type'      => 'int-11',

+ 0 - 11
database/type.php

@@ -34,17 +34,6 @@ return array
             'search'    => 'fulltext',
             'list'      => true,
         ),
-
-        'host'      => array
-        (
-            'type'      => 'varchar-100',
-            'name'      => '域名',
-            'default'   => '',
-            'desc'      => '域名',
-            'match'     => 'is_string',
-            'update'    => 'text',
-            'list'      => true,
-        ),
         
         'state'     => array
         (

+ 8 - 7
lib/Handle.php

@@ -9,16 +9,17 @@ class Handle
     public function showUrl($id)
     {
         $info = Dever::db('short/info')->one($id);
-        $type = Dever::db('short/type')->one($info['type']);
+        $type = Dever::db('short/type')->one($info['type_id']);
+        $host = Dever::db('short/host')->one($info['host_id']);
 
-        return $type['host'] . Dever::uid($id);
+        return $host['name'] . Dever::uid($id);
     }
 
-    public function get($type, $url, $param, $host = '')
+    public function get($host, $url, $param, $host = '')
     {
         $param = json_encode($param);
-        $where['type'] = $type;
-        $type = Dever::db('short/type')->one($type);
+        $where['host_id'] = $host;
+        $host = Dever::db('short/host')->one($host);
         $where['key'] = md5($url . '?' . $param);
 
         $info = Dever::db('short/info')->one($where);
@@ -31,10 +32,10 @@ class Handle
             $id = Dever::db('short/info')->insert($where);
         }
         if ($host) {
-            $type['host'] = $host;
+            $host['name'] = $host;
         }
 
-        return $type['host'] . Dever::uid($id);
+        return $host['name'] . Dever::uid($id);
     }
 
     public function show($str)