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