123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace Upload\Lib;
- use Dever;
- class Manage
- {
- public function import($id, $name, $data)
- {
- $file = Dever::param('file', $data);
- $call = Dever::param('call', $data);
- if ($file && $call) {
- Dever::load($call, $file);
- }
- }
- public function search_tag()
- {
- $name = Dever::input('term');
- $param['name'] = $name;
- $data = Dever::db('upload/tag')->search($param);
- if ($data) {
- return $data;
- } else {
- return array
- (
- 0 => array('id' => -1, 'value' => '没有找到您搜索的数据', 'label' => '没有找到您搜索的数据'),
- );
- }
- }
- public function search_tag_by_ids($id)
- {
- $data = Dever::db('upload/tag')->search($id);
- return $data;
- }
- public function add_tag($id, $name, $data)
- {
- $tag = Dever::param('tag', $data);
- if ($tag) {
- $temp = explode(',', $tag);
- foreach ($temp as $k => $v) {
- $info = Dever::db('upload/tag')->one(array('name' => $v));
- if (!$info) {
- Dever::db('upload/tag')->insert(array('name' => $v));
- }
- }
- }
- }
- public function file($id)
- {
- $info = Dever::db('upload/file')->one($id);
- $table = array();
- $html = '';
- $location = '';
- $config = Dever::db('upload/upload')->one($info['upload']);
- if ($config['yun'] && $config['save_type'] > 2) {
- $yun = Dever::db('upload/yun')->one($config['yun']);
- $link = $yun['host'] . $info['file'];
- $location = $yun['name'] . ':' . $info['file'];
- if ($config['save_type'] == 3) {
- $location = '<br/>' . '本地服务器:' . $info['file'];
- }
- } else {
- $link = Dever::upload('{uploadRes}' . $info['file']);
- $location = '本地服务器:' . $info['file'];
- if ($config['save_type'] == 2) {
- $yun = Dever::db('upload/yun')->one($config['yun']);
- $link = $yun['host'] . $info['file'];
- $location = '<br />' . $yun['name'] . ':' . $info['file'];
- }
- }
-
- if (strstr($info['file'], '.png') || strstr($info['file'], '.jpg') || strstr($info['file'], '.gif')) {
- $html = '<img src="'.$link.'" width="100" />';
- }
- $table['存储位置'] = $location;
- $table['文件名'] = $info['name'];
- $table['文件大小'] = $info['width'] . '*' . $info['height'];
- $html .= Dever::table($table);
- return $html;
- }
- }
|