예제 #1
0
 function get_VMs($user, &$errors)
 {
     global $config, $sess;
     if (!$this->connect_to_db($errors)) {
         return false;
     }
     $q = "select mid, src_addr, inc_time, subject, file from " . $config->data_sql->table_voice_silo . " where " . $this->get_indexing_sql_where_phrase_uri($user);
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         log_errors($res, $errors);
         return false;
     }
     $out = array();
     for ($i = 0; $row = $res->fetchRow(DB_FETCHMODE_OBJECT); $i++) {
         if (date('Y-m-d', $row->inc_time) == date('Y-m-d')) {
             $time = "today " . date('H:i', $row->inc_time);
         } else {
             $time = date('Y-m-d H:i', $row->inc_time);
         }
         $out[$i]['subject'] = $row->subject;
         $out[$i]['src_addr'] = htmlspecialchars($row->src_addr);
         $out[$i]['time'] = $time;
         $out[$i]['url_reply'] = $sess->url("send_im.php?kvrk=" . uniqid("") . "&sip_addr=" . rawURLEncode($row->src_addr));
         $out[$i]['url_get'] = $sess->url("ms_get_v_msg.php?kvrk=" . uniqid("") . "&mid=" . rawURLEncode($row->mid));
         $out[$i]['url_dele'] = $sess->url("message_store.php?kvrk=" . uniqid("") . "&dele_vm=" . rawURLEncode($row->mid));
     }
     $res->free();
     return $out;
 }
예제 #2
0
 function get_IMs($uid)
 {
     global $config, $sess;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     $t_name =& $config->data_sql->msg_silo->table_name;
     /* table's name */
     $c =& $config->data_sql->msg_silo->cols;
     /* col names */
     /* get num rows */
     $q = "select count(*) from " . $t_name . "\n\t\t    where " . $c->uid . " = " . $this->sql_format($uid, "s");
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     $row = $res->fetchRow(DB_FETCHMODE_ORDERED);
     $this->set_num_rows($row[0]);
     $res->free();
     /* if act_row is bigger then num_rows, correct it */
     $this->correct_act_row();
     $q = "select " . $c->mid . ", " . $c->from . ", " . $c->inc_time . ", " . $c->body . " \n\t\t    from " . $t_name . " where " . $c->uid . " = " . $this->sql_format($uid, "s") . $this->get_sql_limit_phrase();
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     $out = array();
     for ($i = 0; $row = $res->fetchRow(DB_FETCHMODE_ASSOC); $i++) {
         $timestamp = gmmktime(substr($row[$c->inc_time], 11, 2), substr($row[$c->inc_time], 14, 2), substr($row[$c->inc_time], 17, 2), substr($row[$c->inc_time], 5, 2), substr($row[$c->inc_time], 8, 2), substr($row[$c->inc_time], 0, 4));
         //year
         if (date('Y-m-d', $timestamp) == date('Y-m-d')) {
             $time = "today " . date('H:i', $timestamp);
         } else {
             $time = date('Y-m-d H:i', $timestamp);
         }
         $out[$i]['src_addr'] = htmlspecialchars($row[$c->from]);
         $out[$i]['raw_src_addr'] = $row[$c->from];
         $out[$i]['mid'] = $row[$c->mid];
         $out[$i]['time'] = $time;
         $out[$i]['timestamp'] = $timestamp;
         $out[$i]['body'] = $row[$c->body];
         $out[$i]['url_reply'] = $sess->url("send_im.php?kvrk=" . uniqid("") . "&sip_addr=" . rawURLEncode($row[$c->from]));
         $out[$i]['url_dele'] = $sess->url("message_store.php?kvrk=" . uniqid("") . "&dele_im=" . rawURLEncode($row[$c->mid]));
     }
     $res->free();
     return $out;
 }
예제 #3
0
 function action_default(&$errors)
 {
     global $data, $sess, $sess_ms_act_row;
     $this->controler->set_timezone();
     $data->set_act_row($sess_ms_act_row);
     if (false === ($this->im = $data->get_IMs($this->user_id->get_uid()))) {
         return false;
     }
     $this->pager['url'] = $_SERVER['PHP_SELF'] . "?kvrk=" . uniqid("") . "&act_row=";
     $this->pager['pos'] = $data->get_act_row();
     $this->pager['items'] = $data->get_num_rows();
     $this->pager['limit'] = $data->get_showed_rows();
     $this->pager['from'] = $data->get_res_from();
     $this->pager['to'] = $data->get_res_to();
     foreach ($this->im as $k => $v) {
         $this->im[$k]['url_reply'] = $sess->url($this->opt['im_sending_script'] . "?kvrk=" . uniqid("") . "&im_sip_addr=" . rawURLEncode($v['raw_src_addr']));
         $this->im[$k]['url_dele'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&im_dele_id=" . rawURLEncode($v['mid']));
     }
     return true;
 }
예제 #4
0
 function get_usrloc(&$errors)
 {
     global $data, $sess;
     if (false === ($this->usrloc = $data->get_usrloc($this->user_id->get_uid(), $errors))) {
         return false;
     }
     foreach ($this->usrloc as $key => $val) {
         $this->usrloc[$key]['url_dele'] = $sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&ul_dele_id=" . rawURLEncode($val['uri']));
         //			$this->usrloc[$key]['url_edit'] = $sess->url($_SERVER['PHP_SELF']."?kvrk=".uniqID("")."&ul_edit_id=".rawURLEncode($val['uri']));
     }
     return true;
 }
 function get_cdr_entries($user, $opt, &$errors)
 {
     global $config, $sip_status_messages_array;
     if (!$this->connect_to_db($errors)) {
         return false;
     }
     $opt_filter_outgoing = isset($opt['filter_outgoing']) ? (bool) $opt['filter_outgoing'] : true;
     $opt_filter_incoming = isset($opt['filter_incoming']) ? (bool) $opt['filter_incoming'] : true;
     $this->cdr_prepare_SQL();
     /* get num rows */
     $num_rows = 0;
     //compose get number of calls queries
     $q = array();
     if ($opt_filter_outgoing) {
         $q = array_merge($q, $this->cdr_get_SQL_select_outgoing_count($user));
     }
     if ($opt_filter_incoming) {
         $q = array_merge($q, $this->cdr_get_SQL_select_incoming_count($user));
     }
     //query DB
     foreach ($q as $row) {
         $res = $this->db->query($row);
         if (DB::isError($res)) {
             log_errors($res, $errors);
             return false;
         }
         $row = $res->fetchRow(DB_FETCHMODE_ORDERED);
         $res->free();
         $num_rows += $row[0];
     }
     $this->set_num_rows($num_rows);
     /* if act_row is bigger then num_rows, correct it */
     $this->correct_act_row();
     //compose final query
     $q = array();
     if ($opt_filter_outgoing) {
         $q[] = $this->cdr_get_SQL_select_outgoing($user);
     }
     if ($opt_filter_incoming) {
         $q[] = $this->cdr_get_SQL_select_incoming($user);
     }
     $q = implode(' union ', $q);
     $q .= $this->cdr_sql['order'] . $this->get_sql_limit_phrase();
     //query DB
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         log_errors($res, $errors);
         return false;
     }
     //prepare output
     $out = array();
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $o = array();
         $timestamp = gmmktime(substr($row->ttime, 11, 2), substr($row->ttime, 14, 2), substr($row->ttime, 17, 2), substr($row->ttime, 5, 2), substr($row->ttime, 8, 2), substr($row->ttime, 0, 4));
         //year
         $ts_stop = gmmktime(substr($row->stop, 11, 2), substr($row->stop, 14, 2), substr($row->stop, 17, 2), substr($row->stop, 5, 2), substr($row->stop, 8, 2), substr($row->stop, 0, 4));
         //year
         if ($timestamp <= 0) {
             $o['time'] = "";
         } else {
             if (date('Y-m-d', $timestamp) == date('Y-m-d')) {
                 $o['time'] = "today " . date('H:i', $timestamp);
             } else {
                 $o['time'] = date('Y-m-d H:i', $timestamp);
             }
         }
         $o['sip_callid'] = $row->sip_callid;
         $o['to_uri'] = $row->to_uri;
         $o['sip_to'] = $row->sip_to;
         /*			if ($row->inv_fromtag==$row->bye_fromtag) $o['hangup']="caller";
         			else if ($row->inv_fromtag==$row->bye_totag) $o['hangup']="callee";
         			else $o['hangup']="n/a"; */
         $o['hangup'] = "n/a";
         $o['length'] = gmdate('H:i:s', $ts_stop - $timestamp);
         $o['url_ctd'] = "javascript: open_ctd_win('" . rawURLEncode($o['to_uri']) . "');";
         $o['sip_to'] = htmlspecialchars(ereg_replace("(.*)(;tag=.*)", "\\1", $o['sip_to']));
         $o['status'] = $this->get_status($o['to_uri'], null);
         $o['name'] = $this->get_user_name_from_phonebook($user, $o['to_uri'], $errors);
         $o['call_dir'] = $row->call_type == 'outgoing' ? 'outgoing' : 'incoming';
         $o['call_type'] = $row->call_type;
         $o['sip_status_code'] = $row->sip_status;
         $o['sip_status'] = isset($sip_status_messages_array[$row->sip_status]) ? $sip_status_messages_array[$row->sip_status] : $row->sip_status;
         $out[] = $o;
     }
     //while
     $res->free();
     return $out;
 }
 function get_phonebook_entries($user, $opt, &$errors)
 {
     global $config, $sess;
     if (!$this->connect_to_db($errors)) {
         return false;
     }
     /* backward compatibility */
     if (!is_array($opt)) {
         $pbid = $opt;
         $opt_get_user_status = true;
         $opt_get_aliases = true;
         $o_order_by = "";
         $o_order_desc = "";
     } else {
         $pbid = isset($opt['pbid']) ? $opt['pbid'] : null;
         $opt_get_user_status = isset($opt['get_user_status']) ? (bool) $opt['get_user_status'] : true;
         $opt_get_aliases = isset($opt['get_user_aliases']) ? (bool) $opt['get_user_aliases'] : true;
         $o_order_by = isset($opt['order_by']) ? $opt['order_by'] : "";
         $o_order_desc = !empty($opt['order_desc']) ? "desc" : "";
     }
     if (!is_null($pbid)) {
         $qw = " and id!=" . $this->sql_format($pbid, "n") . " ";
     } else {
         $qw = "";
     }
     /* get num rows */
     $q = "select count(*) from " . $config->data_sql->table_phonebook . " where " . $this->get_indexing_sql_where_phrase($user) . $qw;
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         log_errors($res, $errors);
         return false;
     }
     $row = $res->fetchRow(DB_FETCHMODE_ORDERED);
     $this->set_num_rows($row[0]);
     $res->free();
     /* if act_row is bigger then num_rows, correct it */
     $this->correct_act_row();
     $q = "select id, fname, lname, sip_uri,\n\t\t           trim(concat(lname, ' ', fname)) as name\n\t\t    from " . $config->data_sql->table_phonebook . " \n\t\t\twhere " . $this->get_indexing_sql_where_phrase($user) . $qw;
     if ($o_order_by) {
         $q .= " order by " . $o_order_by . " " . $o_order_desc;
     }
     $q .= $this->get_sql_limit_phrase();
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         log_errors($res, $errors);
         return false;
     }
     $out = array();
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $out[$row->id]['id'] = $row->id;
         $out[$row->id]['l_name'] = $row->lname;
         $out[$row->id]['f_name'] = $row->fname;
         $out[$row->id]['name'] = $row->name;
         $out[$row->id]['sip_uri'] = $row->sip_uri;
         $out[$row->id]['url_ctd'] = "javascript: open_ctd_win('" . rawURLEncode($row->sip_uri) . "');";
         $out[$row->id]['url_dele'] = $sess->url("phonebook.php?kvrk=" . uniqID("") . "&dele_id=" . $row->id);
         $out[$row->id]['url_edit'] = $sess->url("phonebook.php?kvrk=" . uniqID("") . "&edit_id=" . $row->id);
         if ($opt_get_user_status) {
             $out[$row->id]['status'] = $this->get_status($row->sip_uri, null);
         }
         if ($opt_get_aliases) {
             $out[$row->id]['aliases'] = '';
             if (false === ($aliases = $this->get_aliases_by_uri($row->sip_uri, null))) {
                 continue;
             }
             $alias_arr = array();
             foreach ($aliases as $val) {
                 $alias_arr[] = $val->username;
             }
             $out[$row->id]['aliases'] = implode(", ", $alias_arr);
             $out[$row->id]['uris'] = $aliases;
         }
     }
     $res->free();
     return $out;
 }