Manage.php 2.6 KB

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