PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/ser-0.9.6/serweb-0.9.4/data_layer/method.get_ims.php

#
PHP | 54 lines | 37 code | 12 blank | 5 comment | 6 complexity | e076ad574c18ab43c6f0b70ec1bf3794 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. <?
  2. /*
  3. * $Id: method.get_ims.php,v 1.2 2005/04/11 15:39:25 kozlik Exp $
  4. */
  5. class CData_Layer_get_ims {
  6. var $required_methods = array();
  7. function get_IMs($user, &$errors){
  8. global $config, $sess;
  9. if (!$this->connect_to_db($errors)) return false;
  10. /* get num rows */
  11. $q="select count(*) from ".$config->data_sql->table_message_silo.
  12. " where ".$this->get_indexing_sql_where_phrase($user);
  13. $res=$this->db->query($q);
  14. if (DB::isError($res)) {log_errors($res, $errors); return false;}
  15. $row=$res->fetchRow(DB_FETCHMODE_ORDERED);
  16. $this->set_num_rows($row[0]);
  17. $res->free();
  18. /* if act_row is bigger then num_rows, correct it */
  19. $this->correct_act_row();
  20. $q="select mid, src_addr, inc_time, body from ".
  21. $config->data_sql->table_message_silo.
  22. " where ".$this->get_indexing_sql_where_phrase($user).
  23. " limit ".$this->get_act_row().", ".$this->get_showed_rows();
  24. $res=$this->db->query($q);
  25. if (DB::isError($res)) {log_errors($res, $errors); return false;}
  26. $out=array();
  27. for ($i=0; $row=$res->fetchRow(DB_FETCHMODE_OBJECT); $i++){
  28. if (date('Y-m-d',$row->inc_time)==date('Y-m-d')) $time="today ".date('H:i',$row->inc_time);
  29. else $time=date('Y-m-d H:i',$row->inc_time);
  30. $out[$i]['src_addr'] = htmlspecialchars($row->src_addr);
  31. $out[$i]['raw_src_addr'] = $row->src_addr;
  32. $out[$i]['mid'] = $row->mid;
  33. $out[$i]['time'] = $time;
  34. $out[$i]['body'] = $row->body;
  35. $out[$i]['url_reply']= $sess->url("send_im.php?kvrk=".uniqid("")."&sip_addr=".rawURLEncode($row->src_addr));
  36. $out[$i]['url_dele'] = $sess->url("message_store.php?kvrk=".uniqid("")."&dele_im=".rawURLEncode($row->mid));
  37. }
  38. $res->free();
  39. return $out;
  40. }
  41. }
  42. ?>