chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
 
/*
    [UCenter] (C)2001-2099 Comsenz Inc.
    This is NOT a freeware, use is subject to license terms
 
    $Id: feed.php 1059 2011-03-01 07:25:09Z monkey $
*/
 
!defined('IN_UC') && exit('Access Denied');
 
class feedcontrol extends base {
 
    function __construct() {
        $this->feedcontrol();
    }
 
    function feedcontrol() {
        parent::__construct();
        $this->init_input();
    }
 
    function onadd() {
        $this->load('misc');
        $appid = intval($this->input('appid'));
        $icon = $this->input('icon');
        $uid = intval($this->input('uid'));
        $username = $this->input('username');
        $body_data = $_ENV['misc']->array2string($this->input('body_data'));
        $title_data = $_ENV['misc']->array2string($this->input('title_data'));
 
        $title_template = $this->_parsetemplate($this->input('title_template'));
        $body_template = $this->_parsetemplate($this->input('body_template'));
        $body_general = $this->input('body_general');
        $target_ids = $this->input('target_ids');
        $image_1 = $this->input('image_1');
        $image_1_link = $this->input('image_1_link');
        $image_2 = $this->input('image_2');
        $image_2_link = $this->input('image_2_link');
        $image_3 = $this->input('image_3');
        $image_3_link = $this->input('image_3_link');
        $image_4 = $this->input('image_4');
        $image_4_link = $this->input('image_4_link');
 
        $hash_template = md5($title_template.$body_template);
        $hash_data = md5($title_template.$title_data.$body_template.$body_data);
        $dateline = $this->time;
        $this->db->query("INSERT INTO ".UC_DBTABLEPRE."feeds SET appid='$appid', icon='$icon', uid='$uid', username='$username',
            title_template='$title_template', title_data='$title_data', body_template='$body_template', body_data='$body_data', body_general='$body_general',
            image_1='$image_1', image_1_link='$image_1_link', image_2='$image_2', image_2_link='$image_2_link',
            image_3='$image_3', image_3_link='$image_3_link', image_4='$image_4', image_4_link='$image_4_link',
            hash_template='$hash_template', hash_data='$hash_data', target_ids='$target_ids', dateline='$dateline'");
        return $this->db->insert_id();
    }
 
    function ondelete() {
        $start = $this->input('start');
        $limit = $this->input('limit');
        $end = $start + $limit;
        $this->db->query("DELETE FROM ".UC_DBTABLEPRE."feeds WHERE feedid>'$start' AND feedid<'$end'");
    }
 
    function onget() {
        $this->load('misc');
        $limit = intval($this->input('limit'));
        $delete = $this->input('delete');
        $feedlist = $this->db->fetch_all("SELECT * FROM ".UC_DBTABLEPRE."feeds ORDER BY feedid DESC LIMIT $limit");
        if($feedlist) {
            $maxfeedid = $feedlist[0]['feedid'];
            foreach($feedlist as $key => $feed) {
                $feed['body_data'] = $_ENV['misc']->string2array($feed['body_data']);
                $feed['title_data'] = $_ENV['misc']->string2array($feed['title_data']);
                $feedlist[$key] = $feed;
            }
        }
        if(!empty($feedlist)) {
            if(!isset($delete) || $delete) {
                $this->_delete(0, $maxfeedid);
            }
        }
        return $feedlist;
    }
 
    function _delete($start, $end) {
        $this->db->query("DELETE FROM ".UC_DBTABLEPRE."feeds WHERE feedid>='$start' AND feedid<='$end'");
    }
 
    function _parsetemplate($template) {
        $template = str_replace(array("\r", "\n"), '', $template);
        $template = str_replace(array('<br>', '<br />', '<BR>', '<BR />'), "\n", $template);
        $template = str_replace(array('<b>', '<B>'), '[B]', $template);
        $template = str_replace(array('<i>', '<I>'), '[I]', $template);
        $template = str_replace(array('<u>', '<U>'), '[U]', $template);
        $template = str_replace(array('</b>', '</B>'), '[/B]', $template);
        $template = str_replace(array('</i>', '</I>'), '[/I]', $template);
        $template = str_replace(array('</u>', '</U>'), '[/U]', $template);
        $template = htmlspecialchars($template);
        $template = nl2br($template);
        $template = str_replace(array('[B]', '[I]', '[U]', '[/B]', '[/I]', '[/U]'), array('<b>', '<i>', '<u>', '</b>', '</i>', '</u>'), $template);
        return $template;
    }
 
}
 
?>