} } if (empty($errors)) { $time = strtotime($till); if ($time < 1) { $errors[] = Resources::Get("errors.format", Resources::Get("form.field.till")); } $hashTable = array('till' => date('Y-m-d H:i:s', $time), 'address' => $address, 'comment' => $comment); if ($isCreateMode) { $hashTable['created'] = null; } else { $hashTable['banid'] = $banid; } $banMapper->save($hashTable); header("Location: " . AdminURL::getInstance()->getURL('blocked')); exit; } $TML->assign('address', $address); $TML->assign('till', $till); $TML->assign('comment', $comment); } elseif (isset($_REQUEST['banid'])) { $banid = verify_param('banid', "/^\\d{1,9}\$/"); $ban = $banMapper->getById($banid); $TML->assign('address', $ban['address']); $TML->assign('till', date(getDateTimeFormat(), $ban['till'])); $TML->assign('comment', $ban['comment']); } require_once dirname(__FILE__) . '/inc/admin_prolog_after.php'; $TML->assign('errors', $errors); $TML->display('ban.tpl'); require_once dirname(__FILE__) . '/inc/admin_epilog.php';
/** * Date/Time Output using locale * * @since 1.0 * @param string $dt Date/Time string * @return string */ function output_datetime($dt = null) { if (isset($dt)) { $dt = strtotime($dt); } if (getDateTimeFormat()) { return formatDate(getDateTimeFormat(), $dt); } }
private static function formatThreads($start, $end) { $threads = MapperFactory::getMapper('Thread')->enumByDate($start, $end); $result = ''; foreach ($threads as $thread) { $result .= '#' . $thread['threadid'] . ' ' . date(getDateTimeFormat(), $thread['created']) . "\n"; $result .= "-----------------------------------------------\n"; $lastid = '-1'; $result .= implode("\n", Thread::getInstance()->GetMessages($thread['threadid'], 'text', true, $lastid, true)); $result .= "-----------------------------------------------\n\n\n\n"; } return $result; }
require_once '../classes/models/generic/class.mapperfactory.php'; $operator = Operator::getInstance()->GetLoggedOperator(); $errors = array(); $banMapper = MapperFactory::getMapper('Ban'); if (!empty($_GET['act']) && $_GET['act'] == 'delete') { $banId = isset($_GET['id']) ? $_GET['id'] : ''; if (!preg_match("/^\\d+\$/", $banId)) { $errors[] = 'Wrong argument'; } if (count($errors) == 0) { $banMapper->delete($banId); header('Location: ' . WEBIM_ROOT . '/operator/blocked.php'); exit; } } $blockedList = $banMapper->getAll(); foreach ($blockedList as $k => $v) { $blockedList[$k]['till'] = date(getDateTimeFormat(), $v['till']); } require_once dirname(__FILE__) . '/inc/admin_prolog_after.php'; $TML = new SmartyClass($TITLE_KEY); if (!empty($blockedList)) { $pagination = setup_pagination($blockedList); $tmlPage['pagination'] = $pagination['pagination']; $tmlPage['pagination_items'] = $pagination['pagination_items']; $TML->assign('pagination', generate_pagination($tmlPage['pagination'])); $TML->assign('page_settings', $tmlPage); } $TML->assign('errors', $errors); $TML->display('blocked_visitors.tpl'); require_once dirname(__FILE__) . '/inc/admin_epilog.php';
public function getListThreads($currentoperatorid, $q, $show_empty = true, $checkDepartmentsAccess = true, $start_date = null, $end_date = null, $operatorid = null, $offset = null, $limit = null, $departmentid = null, $locale = null, $rate = null) { $departmentsExist = count(MapperFactory::getMapper("Department")->enumDepartments(Resources::getCurrentLocale())); // TODO probably not the best place $query_params = array(); $sql = ' SELECT WM_UNIX_TIMESTAMP(t."created") "created", WM_UNIX_TIMESTAMP(t."modified") "modified", t."threadid", t."operatorfullname", t."visitormessagecount" as "size", v."ip" as "remote", v."remotehost", v."visitorname" FROM "{thread}" t LEFT JOIN "{visitsession}" v ON v."visitsessionid" = t."visitsessionid" WHERE 1=1'; if (!empty($q)) { $query_params['query'] = "%%{$q}%%"; $sql .= ' AND (t."threadid" IN ( SELECT "threadid" FROM "{message}" m WHERE m."sendername" LIKE :query OR m."message" LIKE :query ) OR v."visitorid" LIKE :query OR v."ip" LIKE :query OR v."remotehost" LIKE :query OR t."operatorfullname" LIKE :query )'; } if (!empty($rate)) { $sign = $rate == 'positive' ? '>' : '<'; $sql .= ' AND EXISTS(SELECT * FROM "{rate}" r WHERE r."threadid"=t."threadid" AND r."rate" ' . $sign . ' 0 AND r."deldate" IS NULL)'; } if ($checkDepartmentsAccess) { $sql .= ' AND (t."departmentid" IS NULL OR EXISTS(SELECT * FROM "{operatordepartment}" od WHERE od."operatorid"=:currentoperatorid AND od."departmentid"=t."departmentid"))'; $query_params['currentoperatorid'] = $currentoperatorid; } if (!$show_empty) { $sql .= ' AND t."visitormessagecount" > 0 '; } if ($start_date !== null) { $query_params['start_date'] = $start_date; $sql .= ' AND WM_UNIX_TIMESTAMP(t."created") >= :start_date'; } if ($end_date !== null) { $query_params['end_date'] = $end_date; $sql .= ' AND WM_UNIX_TIMESTAMP(t."created") < :end_date'; } if ($operatorid !== null) { $query_params['operatorid'] = $operatorid; $sql .= ' AND (:operatorid IS NULL OR t."operatorid"=:operatorid)'; } if (!empty($departmentid)) { $query_params['departmentid'] = $departmentid; $sql .= ' AND t."departmentid" = :departmentid '; } if (!empty($locale)) { $query_params['locale'] = $locale; $sql .= ' AND t."locale" = :locale '; } if ($limit !== null && $offset !== null) { $query_params['limit'] = $limit; $query_params['offset'] = $offset; $sql .= " AND rownum BETWEEN :offset AND :limit"; } $sql .= ' ORDER BY t."created" DESC'; try { $this->db->query($sql, $query_params); $result = $this->db->getArrayOfRows(); } catch (Exception $e) { return array(); } foreach ($result as $k => $v) { $geodata = GeoIPLookup::getGeoDataByIP($v['remote']); //for testing purpose //$geodata = GeoIPLookup::getGeoDataByIP('89.113.218.99'); if ($geodata == NULL) { $geodata = array('city' => null, 'country' => null, 'lat' => null, 'lng' => null); } $result[$k] = array_merge($v, $geodata); $result[$k]['created'] = date(getDateTimeFormat(), $v['created']); $result[$k]['modified'] = date(getDateTimeFormat(), $v['modified']); $result[$k]['diff'] = webim_date_diff($v['modified'] - $v['created']); } return $result; }
private static function formatThreads($start, $end) { $threads = MapperFactory::getMapper("Thread")->enumByDate($start, $end); $result = ""; foreach ($threads as $thread) { $result .= "#" . $thread['threadid'] . " " . date(getDateTimeFormat(), $thread['created']) . "\n"; $result .= "-----------------------------------------------\n"; $lastid = "-1"; $result .= implode("\n", Thread::getInstance()->GetMessages($thread['threadid'], "text", true, $lastid, true)); $result .= "-----------------------------------------------\n\n\n\n"; } return $result; }
public function getListThreads($currentoperatorid, $q, $show_empty = true, $checkDepartmentsAccess = true, $nLimit = 15, $nOffset = 0, $start_date = null, $end_date = null, $operatorid = null, $departmentid = null, $locale = null, $rate = null, $offline = null) { $departmentsExist = count(MapperFactory::getMapper('Department')->enumDepartments(Resources::getCurrentLocale())); // TODO probably not the best place $query_params = array(); $sWhere = ''; $sql = 'SELECT unix_timestamp(t.created) as created, unix_timestamp(t.modified) as modified, t.threadid, t.operatorfullname, t.visitormessagecount as size, v.ip as remote, v.remotehost, v.visitorname FROM {thread} as t LEFT JOIN {visitsession} as v ON v.visitsessionid = t.visitsessionid WHERE 1'; if (!empty($q)) { $query_params['query'] = "%%{$q}%%"; $sWhere .= ' AND (t.threadid IN ( SELECT threadid FROM {message} as m WHERE m.sendername LIKE :query OR m.message LIKE :query ) OR v.visitorid LIKE :query OR v.ip LIKE :query OR v.remotehost LIKE :query OR t.operatorfullname LIKE :query )'; } if (!empty($rate)) { $sign = $rate == 'positive' ? '>' : '<'; $sWhere .= " AND EXISTS (SELECT * FROM {rate} r WHERE r.threadid=t.threadid AND r.rate {$sign} 0 AND r.deldate IS NULL) "; } if ($checkDepartmentsAccess) { $sWhere .= ' AND (t.departmentid IS NULL OR EXISTS(SELECT * FROM {operatordepartment} od WHERE od.operatorid=:currentoperatorid AND od.departmentid=t.departmentid)) '; $query_params['currentoperatorid'] = $currentoperatorid; } if (!$show_empty) { $sWhere .= ' AND t.visitormessagecount > 0 '; } if ($start_date !== null) { $query_params['start_date'] = $start_date; $sWhere .= ' AND unix_timestamp(t.created) >= :start_date'; } if ($end_date !== null) { $query_params['end_date'] = $end_date; $sWhere .= ' AND unix_timestamp(t.created) < :end_date'; } if ($operatorid !== null) { $query_params['operatorid'] = $operatorid; $sWhere .= ' AND (:operatorid IS NULL OR t.operatorid=:operatorid)'; } if (!empty($departmentid)) { $query_params['departmentid'] = $departmentid; $sWhere .= ' AND t.departmentid = :departmentid '; } if (!empty($locale)) { $query_params['locale'] = $locale; $sWhere .= ' AND t.locale = :locale '; } if ($offline !== null) { $query_params['offline'] = $offline; $sWhere .= ' AND t.offline=:offline'; } $sql .= $sWhere . " ORDER BY t.created DESC LIMIT {$nOffset}, {$nLimit}"; try { $this->db->query($sql, $query_params); $result = $this->db->getArrayOfRows(); } catch (Exception $e) { return array(); } foreach ($result as $k => $v) { $geodata = GeoIPLookup::getGeoDataByIP($v['remote']); //for testing purpose //$geodata = GeoIPLookup::getGeoDataByIP('89.113.218.99'); if ($geodata == null) { $geodata = array('city' => null, 'country' => null, 'lat' => null, 'lng' => null); } $result[$k] = array_merge($v, $geodata); $result[$k]['created'] = date(getDateTimeFormat(), $v['created']); $result[$k]['modified'] = date(getDateTimeFormat(), $v['modified']); $result[$k]['diff'] = webim_date_diff($v['modified'] - $v['created']); } return $result; }