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