Пример #1
0
function get_request()
{
    $default_request = array('a' => 'summary');
    $actual_request = array();
    if (isset($_SERVER['PATH_INFO'])) {
        list($null, $actual_request['p'], $actual_request['a'], $actual_request['h'], $actual_request['ext']) = explode('/', $_SERVER['PATH_INFO']);
    } else {
        if ($_SERVER['QUERY_STRING'] != '') {
            $actual_request = split_query_string($_SERVER['QUERY_STRING']);
        }
    }
    return array_merge($default_request, $actual_request);
}
Пример #2
0
/**
 * Get raw results for webservices log search
 *
 * @param object $search - see build_webservice_log_search_results() for
 *                         list of variables
 */
function get_log_search_results($search)
{
    $sort = 'TRUE';
    if (preg_match('/^[a-zA-Z_0-9"]+$/', $search->sortby)) {
        $sort = $search->sortby;
        if (strtoupper($search->sortdir) != 'DESC') {
            $sort .= ' ASC';
        } else {
            $sort .= ' DESC';
        }
    }
    $where = '';
    $ilike = db_ilike();
    $wheres = array();
    $params = array();
    if ($search->protocol != 'all') {
        $wheres[] = ' el.protocol = ? ';
        $params[] = $search->protocol;
    }
    if ($search->authtype != 'all') {
        $wheres[] = ' el.auth = ? ';
        $params[] = $search->authtype;
    }
    if ($search->institution != 'all') {
        $wheres[] = ' el.institution = ? ';
        $params[] = $search->institution;
    }
    if ($search->onlyerrors == 1) {
        $wheres[] = ' TRIM(el.info) > \' \' ';
    }
    if ($search->userquery) {
        $userwheres = array();
        $terms = split_query_string(strtolower(trim($search->userquery)));
        foreach ($terms as $term) {
            foreach (array('u.username', 'u.firstname', 'u.lastname') as $tests) {
                $userwheres[] = ' ' . $tests . ' ' . $ilike . ' \'%' . addslashes($term) . '%\'';
            }
        }
        if (!empty($userwheres)) {
            $wheres[] = ' ( ' . implode(' OR ', $userwheres) . ' ) ';
        }
    }
    if ($search->functionquery) {
        $functionwheres = array();
        $terms = split_query_string(strtolower(trim($search->functionquery)));
        foreach ($terms as $term) {
            $functionwheres[] = ' el.functionname ' . $ilike . ' \'%' . addslashes($term) . '%\'';
        }
        if (!empty($functionwheres)) {
            $wheres[] = ' ( ' . implode(' OR ', $functionwheres) . ' ) ';
        }
    }
    if (empty($wheres)) {
        $wheres[] = ' TRUE ';
    }
    $where = ' WHERE ' . implode(' AND ', $wheres);
    $count = count_records_sql('
            SELECT  COUNT(*)
            FROM {external_services_logs} el
            JOIN {usr} u
                ON el.userid = u.id
            ' . $where, $params);
    $data = get_records_sql_array('
            SELECT  u.username,
                    u.firstname,
                    u.lastname,
                    u.email,
                    el.*
            FROM {external_services_logs} el
            JOIN {usr} u
                ON el.userid = u.id
            ' . $where . ' ORDER BY ' . $search->sortby, $params, $search->offset);
    $results = array('count' => $count, 'limit' => $search->limit, 'offset' => $search->offset, 'data' => array());
    if (!empty($data)) {
        foreach ($data as $row) {
            $row->timelogged = format_date($row->timelogged, 'strftimedatetime');
            $row->institution = institution_display_name($row->institution);
            $results['data'][] = (array) $row;
        }
    }
    return $results;
}
Пример #3
0
 public function link($query)
 {
     $ary = split_query_string($query);
     foreach ($ary as $k => $v) {
         $url[] = $k . '=' . $v;
     }
     return '?' . implode(';', $url);
 }