Manage.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace Upload\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function search_tag()
  7. {
  8. $name = Dever::input('term');
  9. $param['name'] = $name;
  10. $data = Dever::db('upload/tag')->search($param);
  11. if ($data) {
  12. return $data;
  13. } else {
  14. return array
  15. (
  16. 0 => array('id' => -1, 'value' => '没有找到您搜索的数据', 'label' => '没有找到您搜索的数据'),
  17. );
  18. }
  19. }
  20. public function search_tag_by_ids($id)
  21. {
  22. $data = Dever::db('upload/tag')->search($id);
  23. return $data;
  24. }
  25. public function add_tag($id, $name, $data)
  26. {
  27. $tag = Dever::param('tag', $data);
  28. if ($tag) {
  29. $temp = explode(',', $tag);
  30. foreach ($temp as $k => $v) {
  31. $info = Dever::db('upload/tag')->one(array('name' => $v));
  32. if (!$info) {
  33. Dever::db('upload/tag')->insert(array('name' => $v));
  34. }
  35. }
  36. }
  37. }
  38. public function file($id)
  39. {
  40. $info = Dever::db('upload/file')->one($id);
  41. $table = array();
  42. $html = '';
  43. $location = '';
  44. $config = Dever::db('upload/upload')->one($info['upload']);
  45. if ($config['yun'] && $config['save_type'] > 2) {
  46. $yun = Dever::db('upload/yun')->one($config['yun']);
  47. $link = $yun['host'] . $info['file'];
  48. $location = $yun['name'] . ':' . $info['file'];
  49. if ($config['save_type'] == 3) {
  50. $location = '<br/>' . '本地服务器:' . $info['file'];
  51. }
  52. } else {
  53. $link = Dever::upload('{uploadRes}' . $info['file']);
  54. $location = '本地服务器:' . $info['file'];
  55. if ($config['save_type'] == 2) {
  56. $yun = Dever::db('upload/yun')->one($config['yun']);
  57. $link = $yun['host'] . $info['file'];
  58. $location = '<br />' . $yun['name'] . ':' . $info['file'];
  59. }
  60. }
  61. if (strstr($info['file'], '.png') || strstr($info['file'], '.jpg') || strstr($info['file'], '.gif')) {
  62. $html = '<img src="'.$link.'" width="100" />';
  63. }
  64. $table['存储位置'] = $location;
  65. $table['文件名'] = $info['name'];
  66. $table['文件大小'] = $info['width'] . '*' . $info['height'];
  67. $html .= Dever::table($table);
  68. return $html;
  69. }
  70. }