Пример #1
0
	Antall treff: <b>' . $pagei->total . '</b>
</p>
<form action="" method="post">';
            foreach ($_POST as $key => $value) {
                if ($key == "side" || $key == "sort") {
                    continue;
                }
                echo '
	<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
            }
            echo '
	<input type="hidden" name="sort" id="sort_sort" value="' . $sort->active . '" />
	<table class="table" width="100%" id="meldinger">
		<thead>
			<tr>
				<th><span class="tools_r">' . $sort->show_button(0, 1) . '</span> Avsender</th>
				<th><span class="tools_r">' . $sort->show_button(2, 3) . '</span> Emne</th>
				<th><span class="tools_r">' . $sort->show_button(4, 5) . '</span>Innhold</th>
				<th><span class="tools_r">' . $sort->show_button(6, 7) . '</span> Dato</th>
			</tr>
		</thead>
		<tbody>';
            $_base->page->add_css('
.ny { color: #FF0000; font-weight: bold }
.it_u { white-space: nowrap; width: 100px }
.it_dato { text-align: center; white-space: nowrap; color: #888888; width: 100px }
#meldinger a { text-decoration: none }
.utgaaende { color: #888888 }' . ($show_deleted ? '
.slettet { color: #BBBB99 }' : '
.ir_marked { color: #BBBB99; font-weight: bold }'));
            $i = 0;
Пример #2
0
    /** Søkefunksjon */
    public static function action_search()
    {
        access::need("crewet");
        ess::$b->page->add_title("Søk");
        // hvem som skal ha kunnet skrevet det man søker på
        $search_from = array(1 => array("Alle", ""), array("Meg selv", " AND sum_up_id = up_ref.up_id"), array("Andre", " AND sum_up_id != up_ref.up_id"), array('Spesifiser', NULL, array()));
        $id = requestval("f");
        $search_from_id = isset($search_from[$id]) ? $id : 1;
        // sjekk etter spillere?
        if ($search_from_id == 4) {
            $name = trim(postval("up"));
            // sett opp brukernavnene
            $names = explode(",", $name);
            foreach ($names as $name) {
                $name = trim($name);
                if (empty($name)) {
                    continue;
                }
                if (preg_match('/^[0-9a-zA-Z\\-_ ]+$/Du', $name)) {
                    $search_from[4][2][] = $name;
                } else {
                    ess::$b->page->add_message('Ugyldig spillernavn: <b>' . htmlspecialchars($name) . '</b>.', "error");
                }
            }
            if (count($search_from[4][2]) == 0) {
                $search_from_id = 1;
            } else {
                $search_from[4][1] = " AND up_sum.up_name IN (" . implode(",", array_map(array(ess::$b->db, "quote"), $search_from[4][2])) . ")";
            }
        }
        // søke kun blant den som sendte inn henvendelsen eller de som svarte?
        // MERK: tar ikke høyde for at brukere skifter spiller
        $search_by = array(1 => array("Alle", ""), array("Innsender", " AND sum_up_id = su_up_id"), array("Crewet", " AND sum_up_id != su_up_id"));
        $id = requestval("fb");
        $search_by_id = isset($search_by[$id]) ? $id : 1;
        // kategorier
        $search_kat = array();
        foreach (self::$kategorier as $info) {
            $search_kat[$info['id']] = array($info['name'], "su_category = {$info['id']}");
        }
        $search_kat_active = array();
        $search_kat_query = array();
        foreach ($_REQUEST as $key => $dummy) {
            $match = false;
            if (preg_match("/^k(\\d+)\$/Du", $key, $match)) {
                if (isset($search_kat[$match[1]])) {
                    $search_kat_active[] = $match[1];
                    $search_kat_query[] = $search_kat[$match[1]][1];
                }
            }
        }
        if (count($search_kat_query) > 0 && count($search_kat_query) != count($search_kat)) {
            $search_kat_query = " AND (" . implode(" OR ", $search_kat_query) . ")";
            $more = true;
        } else {
            if (count($search_kat_active) == 0) {
                $search_kat_active = array_keys($search_kat);
            }
            $search_kat_query = "";
        }
        // sortering
        $sort = new sorts("sort");
        $sort->append("asc", "Avsender", "up_name, sum_time DESC");
        $sort->append("desc", "Avsender", "up_name DESC, sum_time DESC");
        $sort->append("asc", "Tittel", "su_title, sum_time DESC");
        $sort->append("desc", "Tittel", "su_title DESC, sum_time DESC");
        #$sort->append("asc", "Innhold", "id_text");
        #$sort->append("desc", "Innhold", "id_text DESC");
        $sort->append("asc", "Tid", "sum_time");
        $sort->append("desc", "Tid", "sum_time DESC");
        $sort->set_active(postval("sort"), 5);
        // søkeskjema
        echo '
<h1>Søk i support</h1>
<p class="h_right"><a href="./">Tilbake</a></p>
<form action="" method="post">
	<div class="section" style="width: 410px; margin-left: auto; margin-right: auto">
		<h2>Søk</h2>
		<dl class="dl_20 dl_2x">
			<dt>Tittel</dt>
			<dd><input type="text" name="title" value="' . htmlspecialchars(postval("title")) . '" class="styled w150" /></dd>
			
			<dt>Innhold</dt>
			<dd><input type="text" name="text" value="' . htmlspecialchars(postval("text")) . '" class="styled w300" /></dd>
			
			<dt>Av?</dt>
			<dd>';
        $i = 0;
        foreach ($search_from as $key => $item) {
            if (++$i == count($search_from)) {
                break;
            }
            echo '
				<input type="radio" id="f_' . $key . '" name="f" value="' . $key . '"' . ($search_from_id == $key ? ' checked="checked"' : '') . ' /><label for="f_' . $key . '"> ' . htmlspecialchars($item[0]) . '</label>';
        }
        echo '
			</dd>
			
			<dt>&nbsp;</dt>
			<dd><input type="radio" id="f_' . $key . '" name="f" value="' . $key . '"' . ($search_from_id == $key ? ' checked="checked"' : '') . ' onclick="$(\'u_name\').focus()" /><label for="f_' . $key . '"> Spesifiser: </label><input type="text" name="up" value="' . htmlspecialchars(postval("up")) . '" class="styled w100" id="u_name" onfocus="$(\'f_' . $key . '\').checked=true" /></dd>
			
			<dt>Hvilke meldinger?</dt>
			<dd>';
        foreach ($search_by as $key => $item) {
            echo '
				<input type="radio" id="fb_' . $key . '" name="fb" value="' . $key . '"' . ($search_by_id == $key ? ' checked="checked"' : '') . ' /><label for="fb_' . $key . '"> ' . htmlspecialchars($item[0]) . '</label>';
        }
        echo '
			</dd>
			
			<dt>Kategorier</dt>
			<dd>';
        $i = 0;
        foreach ($search_kat as $key => $item) {
            if ($i++ > 0) {
                echo '<br />';
            }
            echo '
					<input type="checkbox" id="kat?' . $key . '" name="k' . $key . '" value="1"' . (in_array($key, $search_kat_active) ? ' checked="checked"' : '') . ' /><label for="kat_' . $key . '"> ' . htmlspecialchars($item[0]) . '</label>';
        }
        echo '
			</dd>
		</dl>
		<h3 class="c">
			' . show_sbutton("Utfør søk", 'name="search"') . '
		</h3>
	</div>
</form>';
        // søke?
        if (isset($_POST['search'])) {
            $title_search = postval("title");
            $text_search = postval("text");
            // finn ut delene av spørringen
            $title_parts = search_query($title_search);
            $text_parts = search_query($text_search);
            if (count($title_parts[0]) == 0 && count($text_parts[0]) == 0 && $search_from_id != 4 && $search_kat_query == "") {
                echo '
<h2>Søkeresultater</h2>
<p>Ingen søkekriterier.</p>';
            } else {
                // sett opp søkespørringen
                $search = "";
                if (count($title_parts[0]) > 0) {
                    $search .= " AND su_title" . implode(" AND su_title", $title_parts[0]);
                }
                if (count($text_parts[0]) > 0) {
                    $search .= " AND sum_text" . implode(" AND sum_text", $text_parts[0]);
                }
                // sortering
                $sort_info = $sort->active();
                // sidetall - hent henvendelsene på denne siden
                $pagei = new pagei(pagei::ACTIVE_POST, "side", pagei::PER_PAGE, 50);
                $result = $pagei->query("\n\t\t\t\t\tSELECT su_id, su_up_id, su_category, su_title, su_time, su_solved, sum_id, sum_up_id, sum_time, sum_text, up_sum.up_name, up_sum.up_access_level\n\t\t\t\t\tFROM support\n\t\t\t\t\t\tJOIN support_messages ON sum_su_id = su_id\n\t\t\t\t\t\tJOIN users_players up_sum ON up_sum.up_id = sum_up_id,\n\t\t\t\t\t\tusers_players up_ref\n\t\t\t\t\tWHERE up_ref.up_u_id = " . login::$user->id . "{$search_from[$search_from_id][1]}{$search_by[$search_by_id][1]}{$search_kat_query}{$search}\n\t\t\t\t\tGROUP BY sum_id" . (count($text_parts[0]) == 0 && $search_from_id == 1 ? ", su_id" : "") . "\n\t\t\t\t\tORDER BY {$sort_info['params']}", array_merge($title_parts[2], $text_parts[2]));
                $info = array();
                foreach ($title_parts[1] as $part) {
                    $info[] = '<b>Tittel:</b> ' . htmlspecialchars($part);
                }
                foreach ($text_parts[1] as $part) {
                    $info[] = '<b>Innhold:</b> ' . htmlspecialchars($part);
                }
                if ($search_from_id == 4) {
                    if (count($search_from[4][2]) == 1) {
                        $info[] = '<b>Spiller:</b> <user="******" />';
                    } else {
                        $u = array();
                        foreach ($search_from[4][2] as $name) {
                            $u[] = '<user="******" />';
                        }
                        $info[] = '<b>Spiller:</b> ' . implode(" eller ", $u);
                    }
                }
                $info = implode(" ", $info);
                echo '
<h2>Søkeresultater</h2>
<p>Søkekriterier: ' . $info . '</p>';
                // fant vi noe?
                if ($pagei->total == 0) {
                    echo '
<p>Fant ingen treff.</p>';
                } else {
                    echo '
<p>Antall treff: <b>' . $pagei->total . '</b></p>
<form action="" method="post">';
                    foreach ($_POST as $key => $value) {
                        if ($key == "side" || $key == "sort") {
                            continue;
                        }
                        echo '
	<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
                    }
                    echo '
	<input type="hidden" name="sort" id="sort_sort" value="' . $sort->active . '" />
	<table class="table' . ($pagei->pages == 1 ? ' tablemb' : '') . '" width="100%">
		<thead>
			<tr>
				<th><span class="tools_r">' . $sort->show_button(0, 1) . '</span> Spiller</th>
				<th><span class="tools_r">' . $sort->show_button(2, 3) . '</span> Henvendelse</th>
				<th><span class="tools_r">Tekst</th>
				<th><span class="tools_r">' . $sort->show_button(4, 5) . '</span> Tid</th>
			</tr>
		</thead>
		<tbody>';
                    ess::$b->page->add_css('
.su_not_solved { color: #FF0000; font-weight: bold }
.sum_up { white-space: nowrap; width: 100px }
.su_time { text-align: center; white-space: nowrap; color: #888888; width: 100px }');
                    $i = 0;
                    while ($row = $result->fetch()) {
                        $content = trim(strip_tags(game::bb_to_html($row['sum_text'])));
                        $length = mb_strlen($content);
                        $max = 60;
                        if (mb_strlen($content) > $max) {
                            $content = mb_substr($content, 0, $max - 4) . " ...";
                        }
                        echo '
			<tr' . (++$i % 2 == 0 ? ' class="color"' : '') . '>
				<td class="sum_up">' . game::profile_link($row['sum_up_id'], $row['up_name'], $row['up_access_level']) . '</td>
				<td><a href="./?a=show&amp;su_id=' . $row['su_id'] . '">' . htmlspecialchars($row['su_title']) . '</a>' . ($row['su_solved'] == 0 ? ' <span class="su_not_solved">(Uløst)</span>' : '') . '</td>
				<td class="dark">' . htmlspecialchars($content) . ' (' . $length . ' tegn)</td>
				<td class="su_time">' . ess::$b->date->get($row['sum_time'])->format() . '</td>
			</tr>';
                    }
                    echo '
		</tbody>
	</table>';
                    // flere sider?
                    if ($pagei->pages > 1) {
                        echo '
	<div class="hr"></div>
	<p class="c">
		' . $pagei->pagenumbers("input") . '
	</p>';
                    }
                    echo '
</form>';
                }
            }
        }
    }