-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
403 lines (362 loc) · 19.8 KB
/
search.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
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="http://ampleo.mx/misc/favicon.ico" type="image/vnd.microsoft.icon" />
<meta name="Generator" content="Drupal 7 (http://drupal.org)" />
<title>Buscar tu mejor oportunidad | Ampleo | Ama tu Empleo</title>
<link type="text/css" rel="stylesheet" href="http://ampleo.mx/sites/default/files/css/css_Z_KQyXTcIGmFPRfGZOOTJ1xsEckXlqMhF53CkTgnOVA.css" media="all" />
<link type="text/css" rel="stylesheet" href="http://ampleo.mx/sites/default/files/css/css_TsVRTbLFUpEZAfw-_bWPJu840QT523CPjUVJ5MRWfyk.css" media="all" />
<link type="text/css" rel="stylesheet" href="http://ampleo.mx/sites/default/files/css/css_7ROenBG2FuqzPuKZ6fZ5O_1OteZUMPa_fvwzcMMjspg.css" media="all" />
<link type="text/css" rel="stylesheet" href="http://ampleo.mx/sites/default/files/css/css_LbeRP4TJg1C4ZY3u-OCRWDtTyRq439dMcVB2AlzhCyc.css" media="all" />
<!--[if (lt IE 9)&(!IEMobile)]>
<link type="text/css" rel="stylesheet" href="http://ampleo.mx/sites/default/files/css/css_B2TFTXdjv9Mk5rS5-fAprYVTXRigH6jkzdHxP7PgW1c.css" media="all" />
<![endif]-->
<!--[if gte IE 9]><!-->
<link type="text/css" rel="stylesheet" href="http://ampleo.mx/sites/default/files/css/css_fXdHyG4IIkiDHsEc7crzFdMjXP_6OZxaC1No-xMUuPQ.css" media="all" />
<!--<![endif]-->
<script type="text/javascript" src="http://ampleo.mx/misc/jquery.js?v=1.4.4"></script>
<script type="text/javascript" src="http://ampleo.mx/misc/jquery.once.js?v=1.2"></script>
<script type="text/javascript" src="http://ampleo.mx/misc/drupal.js?m5zbn1"></script>
<script type="text/javascript" src="http://ampleo.mx/sites/default/files/languages/es_igA6xPDAt1kA-9vrDANhKxRoaFXZdO-jFmcqdjWGdr4.js?m5zbn1"></script>
<script type="text/javascript" src="http://ampleo.mx/sites/all/modules/panels/js/panels.js?m5zbn1"></script>
<script type="text/javascript" src="http://ampleo.mx/sites/all/themes/omega/omega/js/jquery.formalize.js?m5zbn1"></script>
<script type="text/javascript" src="http://ampleo.mx/sites/all/themes/omega/omega/js/omega-mediaqueries.js?m5zbn1"></script>
<script type="text/javascript" src="http://ampleo.mx/sites/all/themes/omega/omega/js/omega-equalheights.js?m5zbn1"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, {"basePath":"\u002F", "pathPrefix":"", "ajaxPageState":{"theme":"ampleo_theme", "theme_token":"FUqh2blOzqcMYGsrw3mrYYj1s75_ofoEO2bTbG6FkOM", "js":{"misc\u002Fjquery.js":1, "misc\u002Fjquery.once.js":1, "misc\u002Fdrupal.js":1, "public:\u002F\u002Flanguages\u002Fes_igA6xPDAt1kA-9vrDANhKxRoaFXZdO-jFmcqdjWGdr4.js":1, "sites\u002Fall\u002Fmodules\u002Fpanels\u002Fjs\u002Fpanels.js":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Fomega\u002Fjs\u002Fjquery.formalize.js":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Fomega\u002Fjs\u002Fomega-mediaqueries.js":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Fomega\u002Fjs\u002Fomega-equalheights.js":1}, "css":{"modules\u002Fsystem\u002Fsystem.base.css":1, "modules\u002Fsystem\u002Fsystem.menus.css":1, "modules\u002Fsystem\u002Fsystem.messages.css":1, "modules\u002Fsystem\u002Fsystem.theme.css":1, "modules\u002Fcomment\u002Fcomment.css":1, "modules\u002Ffield\u002Ftheme\u002Ffield.css":1, "modules\u002Fnode\u002Fnode.css":1, "modules\u002Fsearch\u002Fsearch.css":1, "modules\u002Fuser\u002Fuser.css":1, "sites\u002Fall\u002Fmodules\u002Fviews\u002Fcss\u002Fviews.css":1, "sites\u002Fall\u002Fmodules\u002Fctools\u002Fcss\u002Fctools.css":1, "sites\u002Fall\u002Fmodules\u002Fpanels\u002Fcss\u002Fpanels.css":1, "sites\u002Fall\u002Fmodules\u002Frate\u002Frate.css":1, "sites\u002Fall\u002Fmodules\u002Fpanels\u002Fplugins\u002Flayouts\u002Fflexible\u002Fflexible.css":1, "public:\u002F\u002Fctools\u002Fcss\u002Fc9990a258933d517f0090947fcc03583.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Falpha\u002Fcss\u002Falpha-reset.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Falpha\u002Fcss\u002Falpha-mobile.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Falpha\u002Fcss\u002Falpha-alpha.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Fomega\u002Fcss\u002Fformalize.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Fomega\u002Fcss\u002Fomega-text.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Fomega\u002Fcss\u002Fomega-branding.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Fomega\u002Fcss\u002Fomega-menu.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Fomega\u002Fcss\u002Fomega-forms.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Fomega\u002Fcss\u002Fomega-visuals.css":1, "sites\u002Fall\u002Fthemes\u002Fampleo_theme\u002Fcss\u002Fglobal.css":1, "ie::normal::sites\u002Fall\u002Fthemes\u002Fampleo_theme\u002Fcss\u002Fampleo-theme-alpha-default.css":1, "ie::normal::sites\u002Fall\u002Fthemes\u002Fampleo_theme\u002Fcss\u002Fampleo-theme-alpha-default-normal.css":1, "ie::normal::sites\u002Fall\u002Fthemes\u002Fomega\u002Falpha\u002Fcss\u002Fgrid\u002Falpha_default\u002Fnormal\u002Falpha-default-normal-12.css":1, "fluid::sites\u002Fall\u002Fthemes\u002Fampleo_theme\u002Fcss\u002Fampleo-theme-alpha-default.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Falpha\u002Fcss\u002Fgrid\u002Falpha_default\u002Ffluid\u002Falpha-default-fluid-12.css":1, "narrow::sites\u002Fall\u002Fthemes\u002Fampleo_theme\u002Fcss\u002Fampleo-theme-alpha-default.css":1, "narrow::sites\u002Fall\u002Fthemes\u002Fampleo_theme\u002Fcss\u002Fampleo-theme-alpha-default-narrow.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Falpha\u002Fcss\u002Fgrid\u002Falpha_default\u002Fnarrow\u002Falpha-default-narrow-12.css":1, "normal::sites\u002Fall\u002Fthemes\u002Fampleo_theme\u002Fcss\u002Fampleo-theme-alpha-default.css":1, "normal::sites\u002Fall\u002Fthemes\u002Fampleo_theme\u002Fcss\u002Fampleo-theme-alpha-default-normal.css":1, "sites\u002Fall\u002Fthemes\u002Fomega\u002Falpha\u002Fcss\u002Fgrid\u002Falpha_default\u002Fnormal\u002Falpha-default-normal-12.css":1}}, "omega":{"layouts":{"primary":"normal", "order":[ "fluid", "narrow", "normal" ], "queries":{"fluid":"all and (min-width: 740px) and (min-device-width: 740px), (max-device-width: 800px) and (min-width: 740px) and (orientation:landscape)", "narrow":"all and (min-width: 740px) and (min-device-width: 740px), (max-device-width: 800px) and (min-width: 740px) and (orientation:landscape)", "normal":"all and (min-width: 980px) and (min-device-width: 980px), all and (max-device-width: 1024px) and (min-width: 1024px) and (orientation:landscape)"}}}});
//--><!]]>
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'GOOGLE_ANALYTICS_URL']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body class="html not-front not-logged-in page-2-column context-2-column">
<div id="skip-link">
<a href="#main-content" class="element-invisible element-focusable">Pasar al contenido principal</a>
</div>
<div class="region region-page-top" id="region-page-top">
<div class="region-inner region-page-top-inner">
</div>
</div> <div class="page clearfix" id="page">
<header id="section-header" class="section section-header">
<div id="zone-branding-wrapper" class="zone-wrapper zone-branding-wrapper clearfix">
<div id="zone-branding" class="zone zone-branding clearfix equal-height-container container-12">
<div class="grid-12 region region-branding equal-height-element" id="region-branding">
<div class="region-inner region-branding-inner equal-height-container">
<div class="branding-data clearfix">
<div class="logo-img">
<a href="/" rel="home" title=""><img src="http://ampleo.mx/images/logo_5.png" alt="" id="logo" /></a> </div>
</div>
</div>
</div> </div>
</div><div id="zone-menu-wrapper" class="zone-wrapper zone-menu-wrapper clearfix">
<div id="zone-menu" class="zone zone-menu clearfix ampleo-primary-menu container-12">
<div class="grid-12 region region-menu" id="region-menu">
<div class="region-inner region-menu-inner">
<nav class="navigation">
<h2 class="element-invisible">Menú principal</h2><ul id="main-menu" class="links inline clearfix main-menu"><li class="menu-246 first"><a href="/" title="">{ Inicio }</a></li><li class="menu-1717"><a href="/perfiles" title="">{ Perfiles de Trabajo }</a></li><li class="menu-468"><a href="/candidatos" title="">{ Candidatos }</a></li><li class="menu-469"><a href="/empresas" title="">{ Empresas }</a></li><li class="menu-1648"><a href="/blog">{ Blog }</a></li><li class="menu-470 last"><a href="/acerca" title="">{ Acerca }</a></li></ul> </nav>
</div>
</div>
</div>
</div></header>
<div id="section-content" class="section section-content">
<div id="zone-content-wrapper" class="zone-wrapper zone-content-wrapper clearfix">
<div id="zone-content" class="zone zone-content clearfix container-12">
<div class="grid-12 region region-content" id="region-content">
<div class="region-inner region-content-inner">
<a id="main-content"></a>
<div class="block block-system block-main block-system-main odd block-without-title" id="block-system-main">
<div class="block-inner clearfix">
<div class="content clearfix">
<div class="panel-flexible panels-flexible-13 clearfix" >
<div class="panel-flexible-inside panels-flexible-13-inside">
<div class="panels-flexible-row panels-flexible-row-13-6 panels-flexible-row-first clearfix ">
<div class="inside panels-flexible-row-inside panels-flexible-row-13-6-inside panels-flexible-row-inside-first clearfix">
<div class="panels-flexible-region panels-flexible-region-13-region_3 panels-flexible-region-first panels-flexible-region-last ">
<div class="inside panels-flexible-region-inside panels-flexible-region-13-region_3-inside panels-flexible-region-inside-first panels-flexible-region-inside-last">
<div class="search-search-form">
<h3>Busca tu próximo empleo en las más grandes bolsas de trabajo.</h3>
<span class="search-input-text">Ingresa una frase o palabra clave</span>
<form method="get" action="#" id="searchform">
<input id="form-input" type="text" name="name"/>
<input id="s-value" type="hidden" name="s" value=""/>
<input id="form-submit" type="submit" name="submit" value="Buscar"/>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="panels-flexible-row panels-flexible-row-13-1 panels-flexible-row-last clearfix ">
<div class="inside panels-flexible-row-inside panels-flexible-row-13-1-inside panels-flexible-row-inside-last clearfix">
<div class="panels-flexible-column panels-flexible-column-13-2 panels-flexible-column-first ">
<div class="inside panels-flexible-column-inside panels-flexible-column-13-2-inside panels-flexible-column-inside-first">
<div class="panels-flexible-region panels-flexible-region-13-region_1 panels-flexible-region-first panels-flexible-region-last ">
<div class="inside panels-flexible-region-inside panels-flexible-region-13-region_1-inside panels-flexible-region-inside-first panels-flexible-region-inside-last">
<?php
require 'indexing.php';
if(isset($_GET['submit'])){
$name=$_GET['name'];
$s=$_GET['s'];
$name=preg_replace("/[^A-Za-z0-9\s\s+]/",'',$name);
$db=mysql_connect("HOST", "DB", "PASSWORD") or die ("Lo sentimos pero estamos experimentando problemas con nuestra base de datos. Favor de intentar de nuevo en unos minutos");
mysql_set_charset('utf8',$db);
//-select the database to use
$mydb=mysql_select_db("DB");
$className = 'Digger';
$results = search($name);
display($results, $name, $s);
mysql_close($db);
}
$common_select = "";
$search_words = array();
function search($for_text){
$search_params = words($for_text);
$wrds = array();
foreach ($search_params as $param){
$param = mysql_real_escape_string($param);
array_push ($wrds, "stem = '$param'");
}
$var1 = join(" OR ", $wrds);
$word_sql = "SELECT * from words where $var1";
global $search_words;
$words_query = mysql_query($word_sql) or die(mysql_error());
$num_rows = mysql_num_rows($words_query);
if($num_rows == 0){
die ("<div class =\"no-results\">Lo sentimos pero no tenemos resultados para \"$for_text\". Por favor intenta de nuevo con otra frase o palabra clave.</div>");}
$tables = array();
$joins = array();
$ids = array();
$index = 0;
while($row = mysql_fetch_array($words_query)){
$search_words[$index] = $row;
array_push($tables, "locations loc$index");
$j = $index + 1;
array_push ($joins, "loc$index.page_id = loc$j.page_id");
$w = $row['id'];
array_push ($ids, "loc$index.word_id = $w");
$index++;
}
array_pop($joins);
global $common_select;
$var2 = join(', ', $tables);
$var3 = join(' and ', array_merge($joins, $ids));
$common_select = "from $var2 where $var3 group by loc0.page_id";
$result = rank();
return $result;
}
function display($results, $name, $s){
$searchLimit = 99;
$limit=10;
$not_found = "Pagina_No_Encontrada";
$var = array();
$j = 0;
foreach($results as $result => $index){
if($j > $searchLimit){break;}
array_push($var, "id = $result");
$j++;
}
$var2 = join(' or ', $var);
$display_sql = "SELECT url, title from pages where $var2 order by updated_at";
$numrows = 100;
if (empty($s)) {
$s=0; }
$display_sql .= " limit $s,$limit";
$result = mysql_query($display_sql);
$count = 1 + $s ;
echo "<div class =\"search-results\">";
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<div class=\"search-terms\"><p>Mostrando resultados $b a $a de $numrows para <span class=\"search-terms-blue\">$name</span></p></div><br />";
while($list = mysql_fetch_assoc($result)){
echo "<div class =\"search-each-result\">";
echo "<div class=\"search-item\">".$count.".</div>";
echo "<div class=\"search-result\">";
$url = $list['url'];
$pos = strpos($list['title'], $not_found);
if($pos === false) {
echo "<span class=\"search-title\">"."<a href = $url target = \"blank\">".$list['title']."</a></span><br />";}
else {
echo "<span class=\"search-title\">"."<a href = $url target = \"blank\">".$url."</a></span><br />";}
echo "<span class=\"search-url\">".$url."</span><br />";
echo "</div>";
echo "</div>";
$count++;
}
$currPage = (($s/$limit) + 1);
echo "<br />";
// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print " <a href=\"".$_SERVER['PHP_SELF']."?s=$prevs&name=$name&submit=Buscar\"><<
Ultimos 10</a> "; }
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++; }
// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$news=$s+$limit;
echo " <a href=\"".$_SERVER['PHP_SELF']."?s=$news&name=$name&submit=Buscar\">Próx 10 >></a>";
}
echo "</div>";
}
function rank(){
return merge_rankings(frequency_ranking(), location_ranking(), distance_ranking());
}
function frequency_ranking(){
global $common_select;
$freq_sql = "select loc0.page_id, count(loc0.page_id) as count $common_select order by count desc";
$list = mysql_query($freq_sql);
$rank = array();
$floatval = array();
$i = 0;
while($row = mysql_fetch_array($list)){
$floatval[$i] = $row['count'];
$rank[$row['page_id']] = floatval($floatval[$i])/floatval($floatval[0]);
$i++;
}
return $rank;
}
function location_ranking(){
$total = array();
global $search_words;
$index = 0;
$end = count($search_words);
for($index = 0; $index < $end; $index++){
array_push($total, "loc$index.position + 1");
}
$var4 = join(' + ', $total);
global $common_select;
$loc_sql = "select loc0.page_id, ($var4) as total $common_select order by total asc";
$list_query = mysql_query($loc_sql);
$rank = array();
$i = 0;
while($row = mysql_fetch_array($list_query)){
$floatval[$i] = $row['total'];
$rank[$row['page_id']] = floatval($floatval[0])/floatval($floatval[$i]);
$i++;
}
return $rank;
}
function distance_ranking(){
global $search_words;
if(count($search_words) == 1){
$empty = array();
return $empty;
}
$dist = array();
$total = array();
$index = 0;
$end = count($search_words);
for($index = 0; $index < $end; $index++){
array_push($total, "loc$index.position");
}
$end = count($total);
for($i = 0; $i < $end; $i++){
if ($i != ($end - 1)){
$j = $i + 1;
array_push($dist, "abs($total[$i] - $total[$j])");
}
}
$var5 = join(' + ', $dist);
global $common_select;
$dist_sql = "select loc0.page_id, ($var5) as dist $common_select order by dist asc";
$list_query = mysql_query($dist_sql);
$rank = array();
$i = 0;
while($row = mysql_fetch_array($list_query)){
$floatval[$i] = $row['dist'];
$rank[$row['page_id']] = floatval($floatval[0])/floatval($floatval[$i]);
$i++;
}
return $rank;
}
function merge_rankings($rankings){
$numargs = func_num_args();
$arg_list = func_get_args();
$out = array();
// Loop through each of the arguments
for ($i = 0; $i < $numargs; $i++) {
$in = $arg_list[$i];
foreach($in as $key => $value) {
if(array_key_exists($key, $out)) {
$sum = $in[$key] + $out[$key];
$out[$key] = $sum;
}else{
$out[$key] = $in[$key];
}
}
}
arsort($out);
return $out;
}
?>
</div>
</div>
</div>
</div>
<div class="panels-flexible-column panels-flexible-column-13-3 panels-flexible-column-last ">
<div class="inside panels-flexible-column-inside panels-flexible-column-13-3-inside panels-flexible-column-inside-last">
<div class="panels-flexible-region panels-flexible-region-13-region_2 panels-flexible-region-first panels-flexible-region-last ">
<div class="inside panels-flexible-region-inside panels-flexible-region-13-region_2-inside panels-flexible-region-inside-first panels-flexible-region-inside-last">
<div class="ad-sense">
<script type="text/javascript"><!--
google_ad_client = "GOOGLE_ADS";
/* 3rd Iteration of sidebar */
google_ad_slot = "4551133943";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div></div>
<footer id="section-footer" class="section section-footer">
<div id="zone-footer-wrapper" class="zone-wrapper zone-footer-wrapper clearfix">
<div id="zone-footer" class="zone zone-footer clearfix container-12">
<div class="grid-12 region region-footer-first" id="region-footer-first">
<div class="region-inner region-footer-first-inner">
<div class="block block-block block-13 block-block-13 odd block-without-title" id="block-block-13">
<div class="block-inner clearfix">
<div class="content clearfix">
<p style="text-align: right;">Contactar: <a href="mailto:contact@ampleo.mx">contact@ampleo.mx</a></p>
</div>
</div>
</div><div class="block block-block block-14 block-block-14 even block-without-title" id="block-block-14">
<div class="block-inner clearfix">
<div class="content clearfix">
<p style="line-height: 0px;"><a href="/privacidad">Aviso de Privacidad</a> | <a href="/terminos-de-uso">Términos de Uso</a></p>
<p style="line-height: 0px;">© 2011-2012 Abare Consulting S.A. de C.V., Distrito Federal</p>
</div>
</div>
</div> </div>
</div> </div>
</div></footer> </div> </body>
</html>