forked from creativecommons/search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
403 lines (346 loc) · 14.6 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<?php
/**
* If $engine is set in the request, then the user must have javascript turned
* off, else they would have gone directly to the search site, and not back to
* index.php. This block handles those who don't uses javascript for whatever
* reason and could therefor be easily used as an API.
*/
$query = isset($_REQUEST['query']) ? $_REQUEST['query'] : ''; // moving this here, we want to let people search and come here
if ( isset($_REQUEST['engine']) && $_REQUEST['query'] != "" ) {
$engine = $_REQUEST['engine'];
$comm = isset($_REQUEST['comm']) ? TRUE : FALSE;
$deriv = isset($_REQUEST['deriv']) ? TRUE : FALSE;
// We never want the search to execute with the default text
if ( $query == "Enter search query" ) {
$query = "flowers";
}
$rights = modRights($engine, $comm, $deriv);
$url = "";
// NOTE: if you make changes here, you should make a similar change in search.js
switch ( $engine ) {
case "openclipart":
$url = 'http://openclipart.org/search/?query=' . $query;
break;
case "jamendo":
if ( $rights ) {
$url = 'http://www.jamendo.com/search?qs=fq=license_cc:(' . $rights . ')&q=' . $query;
} else {
$url = 'http://www.jamendo.com/search?qs=q=' . $query;
}
break;
case "flickr":
$url = 'http://flickr.com/search/?' . $rights . '&q=' . $query;
break;
case "wikimediacommons":
$url = 'http://commons.wikimedia.org/w/index.php?title=Special%3ASearch&redirs=0&search=' . $query . '&fulltext=Search&ns0=1&ns6=1&ns14=1&title=Special%3ASearch&advanced=1&fulltext=Advanced+search';
break;
case "fotopedia":
$url = 'http://www.fotopedia.com/search?q=' . $query . '&human_license=' . $rights;
break;
case "europeana":
$url = 'http://www.europeana.eu/portal/search.html?query=' . $query . $rights;
break;
case "youtube":
$url = 'http://www.youtube.com/results?search_query=' . $query . ',creativecommons';
break;
case "ccmixter":
$url = 'http://ccmixter.org/api/query?datasource=uploads&search_type=all&sort=rank&search=' . $query . $rights;
break;
case "soundcloud":
$url = 'https://soundcloud.com/search/sounds?q=' . $query . $rights;
break;
case "thingiverse":
$url = 'https://www.thingiverse.com/search?q=' . $query . $rights;
break;
case "googleimg":
$url = 'https://www.google.com/search?site=imghp&tbm=isch&q=';
case "google":
default:
$url = $url ? $url : 'http://google.com/search?q=';
$url .= $query . '&as_rights=' . $rights;
break;
}
$url = urlencode($url);
header('Location: https://oldsearch.creativecommons.org/bouncer.php?q=' . $query . '&url=' . $url);
exit;
}
/**
* Sets up the right query string for the various content providers.
*/
function modRights($engine, $comm, $deriv) {
$rights = "";
switch ( $engine ) {
case "google":
case "googleimg":
/*
fmc Labeled for reuse with modification
fc Labeled for reuse
fm Labeled for noncommercial reuse with modification
f Labeled for noncommercial reuse
*/
$rights = "&tbs=sur:f";
$rights .= $comm ? "m" : "";
$rights .= $deriv ? "c" : "";
break;
case "thingiverse":
/*
If $comm or $deriv is provided, then we first apply the filter
to capture only results of type "things" before adding the specifics we require because
the "customizable" and "licence" filters on thingiverse only work alongside the "things" filter
*/
if ($comm || $deriv) {
$rights = "&type=things&sort=relevant";
$rights .= $deriv ? "&customizable=1" : "";
// Used the licence=cc (which on Thingiverse, stands for the Creative Commons Attribution license)
// as the equivalent for the "modify, reuse ..." filter on CC search
$rights .= $comm ? "&license=cc": "";
}
break;
case "flickr":
$rights = "l=";
$rights .= $comm ? "comm" : "";
$rights .= $deriv ? "deriv" : "";
$rights = ($rights == "l=") ? "l=cc" : $rights;
break;
case "jamendo":
if ( $comm && $deriv ) {
$rights = '-nc%20AND%20-nd';
} elseif ( $comm ) {
$rights = '-nc';
} elseif ( $deriv ) {
$rights = '-nd';
}
break;
case "fotopedia":
if ( $comm && $deriv ) {
$rights = "reuse_commercial_modify";
} else if ( $comm && ! $deriv ) {
$rights = "reuse_commercial";
} else if ( ! $comm && $deriv ) {
$rights = "reuse_modify";
} else {
$rights = "reuse";
}
break;
case "europeana":
if ( $comm && $deriv ) {
$rights = "+AND+RIGHTS%3A*creative*+AND+NOT+RIGHTS%3A*nc*+AND+NOT+RIGHTS%3A*nd*";
} else if ( $comm && ! $deriv ) {
$rights = "+AND+RIGHTS%3A*creative*+AND+NOT+RIGHTS%3A*nc*";
} else if ( ! $comm && $deriv ) {
$rights = "+AND+RIGHTS%3A*creative*+AND+NOT+RIGHTS%3A*nd*";
} else {
$rights = "+AND+RIGHTS%3A*creative*+";
}
break;
case "ccmixter":
if ( $comm && $deriv ) {
$rights = "&lic=by,sa,s,splus,pd,zero";
} else if ( $comm && ! $deriv ) {
$rights = "&lic=open";
} else if ( ! $comm && $deriv) {
$rights = "&lic=by,nc,sa,ncsa,s,splus,pd,zero";
}
break;
case "soundcloud":
if ( $comm && $deriv ) {
$rights = "&filter.license=to_modify_commercially";
} else if ( $comm && ! $deriv ) {
$rights = "&filter.license=to_use_commercially";
} else if ( (! $comm && $deriv) || (! $comm && ! $deriv) ) {
$rights = "&filter.license=to_share";
}
break;
}
return $rights;
}
// adaptor code for cc-wp theme
if ( ! function_exists('bloginfo') ) {
function bloginfo ($param) {
if ( $param == 'home' )
print 'http://creativecommons.org';
if ( $param == 'stylesheet_directory' ) {
// print $theme_path . '/cc-wp';
print '/cc-wp';
}
}
}
if ( ! function_exists('get_http_security') ) {
function get_http_security () {
echo 'https';
}
}
include_once 'cc-wp/meta.php';
include_once 'cc-wp/header-doctype.php'; ?>
<html lang="en">
<head>
<title>CC Search Portal</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<?php include 'cc-wp/header-common.php'; ?>
<link rel="search" type="application/opensearchdescription+xml" title="Creative Commons Search Portal" href="http://oldsearch.creativecommons.org/ccsearch.xml" />
<link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<!--[if lte IE 7]>
<link rel="stylesheet" href="style-ie.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="search.js" type="text/javascript" charset="utf-8"></script>
<script src="elog/elog.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="container">
<?php include 'cc-wp/page-nav.php'; ?>
<div id="main" role="main">
<div class="container">
<div class="sixteen columns">
<div class="first row">
<div class="sixteen columns alpha wrong">
<h3>Try <a href="https://wordpress.org/openverse/?referrer=creativecommons.org">Openverse</a>: Openly Licensed Images, Audio and More.</h3>
</div>
</div>
<div class="row">
<div id="search">
<form id="search_form" method="get" onsubmit="return doSearch()">
<div class="seven columns alpha">
<div id="header_logo" title="To search, enter some search terms, then click a provider." onclick="if ( $('#query').val() ) { doSearch(); }">
<img src="cc-search-portal.png" alt="CC Search Portal" />
<div id="header_text"><span style="color: white;">Find content you can share, use and remix</span></div>
</div>
</div>
<div class="nine columns omega re">
<input type="text" id="query" name="query" value="<?php echo $query; ?>" placeholder="Enter your search query"/>
<div id="secondaryOptions">
<fieldset id="permissions">
<small>
<div class="statement">
<strong>I want something that I can...</strong>
</div>
<div class="permoptions">
<input type="checkbox" name="comm" value="" id="comm" checked="checked" onclick="setCommDeriv()" />
<label for="comm" onclick="setCommDeriv()">use for <em>commercial purposes</em>;</label>
</div>
<div class="permoptions">
<input type="checkbox" name="deriv" value="" id="deriv" checked="checked" onclick="setCommDeriv()" />
<label for="deriv" onclick="setCommDeriv()"><em>modify</em>, <em>adapt</em>, or <em>build upon</em>.</label><br/>
</div>
</small>
</fieldset>
</div>
</div>
<fieldset id="engines">
<p style="text-align:left;"><strong>Search using:</strong></p>
<div class="first row">
<div class="four columns alpha">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="ccmixter" id="ccmixter"></button>
</div>
<div class="engineDesc"><label for="ccmixter"><strong>ccMixter</strong><br/>Music</label></div>
</div>
</div>
<div class="four columns">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="europeana" id="europeana"></button>
</div>
<div class="engineDesc"><label for="europeana"><strong>Europeana</strong><br/>Media</label></div>
</div>
</div>
<div class="four columns">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="flickr" id="flickr"></button>
</div>
<div class="engineDesc"><label for="flickr"><strong>Flickr</strong><br/>Image</label></div>
</div>
</div>
<div class="four columns omega">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="google" id="google"></button>
</div>
<div class="engineDesc"><label for="google"><strong>Google</strong><br/>Web</label></div>
</div>
</div>
</div>
<div class="row">
<div class="four columns alpha">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="googleimg" id="googleimg"></button>
</div>
<div class="engineDesc"><label for="googleimg"><strong>Google Images</strong><br/>Image</label></div>
</div>
</div>
<div class="four columns">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="jamendo" id="jamendo"></button>
</div>
<div class="engineDesc"><label for="jamendo"><strong>Jamendo</strong><br/>Music</label></div>
</div>
</div>
<div class="four columns">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="openclipart" id="openclipart"></button>
</div>
<div class="engineDesc"><label for="openclipart"><strong>Open ClipArt</strong><br/>Image</label></div>
</div>
</div>
</div>
<div class="row">
<div class="four columns alpha">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="soundcloud" id="soundcloud"></button>
</div>
<div class="engineDesc"><label for="soundcloud"><strong>SoundCloud</strong><br/>Music</label></div>
</div>
</div>
<div class="four columns">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="wikimediacommons" id="wikimediacommons"></button>
</div>
<div class="engineDesc"><label for="wikimediacommons"><strong>Wikimedia Commons</strong><br/>Media</label></div>
</div>
</div>
<div class="four columns omega">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="youtube" id="youtube"></button>
</div>
<div class="engineDesc"><label for="youtube"><strong>YouTube</strong><br/>Video</label></div>
</div>
</div>
</div>
<div class="row">
<div class="four columns alpha">
<div class="engine">
<div class="engineButton">
<button onclick="setEngine(this)" name="engine" value="thingiverse" id="thingiverse"></button>
</div>
<div class="engineDesc"><label for="thingiverse"><strong>Thingiverse</strong><br/>3D Model</label></div>
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
<div class="row">
<div id="help">
<div class="one columns alpha">
<p>Please note that CC Search Portal is <em>not a search engine</em>, but rather offers convenient access to search services provided by other independent organizations. CC has no control over the results that are returned. <em>Do not assume that the results displayed in this search portal are under a CC license</em>. You should always verify that the work is actually under a CC license by following the link. Since there is no registration to use a CC license, CC has no way to determine what has and hasn't been placed under the terms of a CC license. If you are in doubt you should contact the copyright holder directly, or try to contact the site where you found the content.</p>
</div>
</div>
</div>
</div><!--! end of .container -->
</div><!--! end of #main -->
<?php include 'cc-wp/page-footer.php'; ?>
</div> <!--! end of #container -->
<?php include 'cc-wp/footer-codes.php'; ?>
<script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us13.list-manage.com","uuid":"4051250396fe81f55034e2d49","lid":"5b82643372"}) })</script>
</body>
</html>