index.php 4.19 KB
Newer Older
1
2
<?php

Brett Bieber's avatar
Brett Bieber committed
3
require_once dirname(__FILE__).'/../config.sample.php';
4
5
6
7
8
9
10
11

UNL_Templates::$options['version'] = 3;

$page = UNL_Templates::factory('Fixed');
$page->doctitle = '<title>UNL | Search</title>';
$local_results = '';
$page->head .= '
<script src="http://www.google.com/jsapi?key=ABQIAAAAfxH7RKwDLHYhDD9dSUZe-RTELkNjcWhKXky6vQZrvQAPA5Uw6xR-eQp2X1fKnLG-UqeKQ_7mwv5CcQ" type="text/javascript"></script>
12
<link rel="stylesheet" type="text/css" href="http://directory.unl.edu/css/peoplefinder_default.css" />
13
<link rel="stylesheet" type="text/css" href="searchCSS.css" />
14
15
16
';
$page->addScript('searchFunc.js');

17
if (isset($_GET['u']) //u is referring site
18
19
20
    && preg_match('/^https?/', $_GET['u'])
    && filter_var($_GET['u'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)
    && $scanned = @file_get_contents($_GET['u'])) {
21
    // Add local site search results
22
    $scanned = new UNL_Templates_Scanner($scanned);
23
    if (isset($scanned->navlinks)) { //we're scrapping the navigation and other content from the originatting site.
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
        require_once 'HTMLPurifier.auto.php';
        $config = HTMLPurifier_Config::createDefault();
        $config->set('Cache.SerializerPath', '/tmp');
        $purifier = new HTMLPurifier($config);
        
        $page->head        .= '<link rel="home" href="'.htmlentities($_GET['u'], ENT_QUOTES).'" />';
        $page->breadcrumbs  = $purifier->purify(UNL_Search::removeRelativePaths($scanned->breadcrumbs, $_GET['u']));
        $page->titlegraphic = $purifier->purify($scanned->titlegraphic);
        $page->navlinks     = $purifier->purify(UNL_Search::removeRelativePaths($scanned->navlinks, $_GET['u']));
        if (!empty($scanned->leftcollinks)) {
            $page->leftcollinks = $purifier->purify($scanned->leftcollinks);
        }
        if (!empty($scanned->contactinfo)) {
            $page->contactinfo = $purifier->purify($scanned->contactinfo);
        }
39
40
41
        if (!empty($scanned->footercontent)) {
            $page->footercontent = $purifier->purify($scanned->footercontent);
        }
42
    }
43
44
45
    
    if (isset($_GET['cx'])) {
        // Use their custom search engine instead of the linked one.
Brett Bieber's avatar
Brett Bieber committed
46
        $context = '"'.htmlentities($_GET['cx'], ENT_QUOTES).'"';
47
48
49
50
    } else {
        // Auto-build a custom search engine
        $context = '{crefUrl :"http://www1.unl.edu/search/linkedcse/?u='.$_GET['u'].'"}';
    }
51
    $page->addScriptDeclaration('
Brett Bieber's avatar
Brett Bieber committed
52
        UNL_Search.do_local_search = true;
53
        UNL_Search.local_search_context = '.$context.';
Brett Bieber's avatar
Brett Bieber committed
54
    ');
55
56
57
58
59
60
61
    $local_results = '
    <h3 class="sec_header">Local Results</h3>
    <div id="local_results"></div>';
} else {
    // Default search for no referring site.
    $page->titlegraphic = '<h1>UNL Search</h1>';
    $page->addScriptDeclaration('UNL_Search.do_local_search = false;');
Brett Bieber's avatar
Brett Bieber committed
62
63
64
65
66
    $page->breadcrumbs   = str_replace('Department', 'Search', $page->breadcrumbs);
    $page->navlinks      = file_get_contents('http://www.unl.edu/ucomm/sharedcode/navigation.html');
    $page->leftcollinks  = file_get_contents('http://www.unl.edu/ucomm/sharedcode/relatedLinks.html');
    $page->contactinfo   = file_get_contents('http://www.unl.edu/ucomm/sharedcode/footerContactInfo.html');
    $page->footercontent = file_get_contents('http://www.unl.edu/ucomm/sharedcode/footer.html');
67
68
69
70
71
72
73
 
}


$page->maincontentarea = '
<div id="searchform">
  <form action="http://www1.unl.edu/search/" method="get">
74
75
  	<label for="q">Search</label>
    <input type="text" name="q" id="q" />';
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
if (!empty($local_results)) {
    $page->maincontentarea .= '<input type="hidden" name="u" value="'.htmlentities($_GET['u'], ENT_QUOTES).'" />';
}
$page->maincontentarea .= '
    <input type="submit" value="Search" />
  </form>
  <noscript>
    <form action="http://www.googlesyndicatedsearch.com/u/UNL1" method="get">
        <input style="width:90%" type="text" name="q" />
        <input type="submit" value="Search" />
    </form>
  </noscript>
</div>
<div class="three_col left">
    '.$local_results.'
    <h3 class="sec_header">UNL Web</h3>
    <div id="unl_results"></div>
</div>
94
95
96
97
98
<div class="col right">
    <h3 class="sec_header">UNL Directory</h3>
    <div id="ppl_results"></div>
    <a href="http://www1.unl.edu/wdn/wiki/About_Peoplefinder">About the UNL Directory</a>
</div>
99
100
101
102
';
echo $page;

?>