feed.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: feed.php 1059 2011-03-01 07:25:09Z monkey $
  6. */
  7. !defined('IN_UC') && exit('Access Denied');
  8. class feedmodel {
  9. var $db;
  10. var $base;
  11. var $apps;
  12. var $operations = array();
  13. function __construct(&$base) {
  14. $this->feedmodel($base);
  15. }
  16. function feedmodel(&$base) {
  17. $this->base = $base;
  18. $this->db = $base->db;
  19. }
  20. function get_total_num() {
  21. $data = $this->db->result_first("SELECT COUNT(*) FROM ".UC_DBTABLEPRE."feeds");
  22. return $data;
  23. }
  24. function get_list($page, $ppp, $totalnum) {
  25. $start = $this->base->page_get_start($page, $ppp, $totalnum);
  26. $data = $this->db->fetch_all("SELECT * FROM ".UC_DBTABLEPRE."feeds LIMIT $start, $ppp");
  27. foreach((array)$data as $k=> $v) {
  28. $searchs = $replaces = array();
  29. $title_data = $_ENV['misc']->string2array($v['title_data']);
  30. foreach(array_keys($title_data) as $key) {
  31. $searchs[] = '{'.$key.'}';
  32. $replaces[] = $title_data[$key];
  33. }
  34. $searchs[] = '{actor}';
  35. $replaces[] = $v['username'];
  36. $searchs[] = '{app}';
  37. $replaces[] = $this->base->apps[$v['appid']]['name'];
  38. $data[$k]['title_template'] = str_replace($searchs, $replaces, $data[$k]['title_template']);
  39. $data[$k]['dateline'] = $v['dateline'] ? $this->base->date($data[$k]['dateline']) : '';
  40. }
  41. return $data;
  42. }
  43. }
  44. ?>