tag.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: tag.php 1059 2011-03-01 07:25:09Z monkey $
  6. */
  7. !defined('IN_UC') && exit('Access Denied');
  8. class tagcontrol extends base {
  9. function __construct() {
  10. $this->tagcontrol();
  11. }
  12. function tagcontrol() {
  13. parent::__construct();
  14. $this->init_input();
  15. $this->load('tag');
  16. $this->load('misc');
  17. }
  18. function ongettag() {
  19. $appid = $this->input('appid');
  20. $tagname = $this->input('tagname');
  21. $nums = $this->input('nums');
  22. if(empty($tagname)) {
  23. return NULL;
  24. }
  25. $return = $apparray = $appadd = array();
  26. if($nums && is_array($nums)) {
  27. foreach($nums as $k => $num) {
  28. $apparray[$k] = $k;
  29. }
  30. }
  31. $data = $_ENV['tag']->get_tag_by_name($tagname);
  32. if($data) {
  33. $apparraynew = array();
  34. foreach($data as $tagdata) {
  35. $row = $r = array();
  36. $tmp = explode("\t", $tagdata['data']);
  37. $type = $tmp[0];
  38. array_shift($tmp);
  39. foreach($tmp as $tmp1) {
  40. $tmp1 != '' && $r[] = $_ENV['misc']->string2array($tmp1);
  41. }
  42. if(in_array($tagdata['appid'], $apparray)) {
  43. if($tagdata['expiration'] > 0 && $this->time - $tagdata['expiration'] > 3600) {
  44. $appadd[] = $tagdata['appid'];
  45. $_ENV['tag']->formatcache($tagdata['appid'], $tagname);
  46. } else {
  47. $apparraynew[] = $tagdata['appid'];
  48. }
  49. $datakey = array();
  50. $count = 0;
  51. foreach($r as $data) {
  52. $return[$tagdata['appid']]['data'][] = $data;
  53. $return[$tagdata['appid']]['type'] = $type;
  54. $count++;
  55. if($count >= $nums[$tagdata['appid']]) {
  56. break;
  57. }
  58. }
  59. }
  60. }
  61. $apparray = array_diff($apparray, $apparraynew);
  62. } else {
  63. foreach($apparray as $appid) {
  64. $_ENV['tag']->formatcache($appid, $tagname);
  65. }
  66. }
  67. if($apparray) {
  68. $this->load('note');
  69. $_ENV['note']->add('gettag', "id=$tagname", '', $appadd, -1);
  70. }
  71. return $return;
  72. }
  73. }
  74. ?>