252 lines
11 KiB
PHP
252 lines
11 KiB
PHP
<?PHP
|
|
ini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL);
|
|
$StartTime=date('H:i:s');
|
|
$home_dir=__DIR__;
|
|
include_once('TSfun.php');
|
|
$UPD=date('Y-m-d');$UPT=date('H:i:s');
|
|
$qq=$quary=NULL;$THits=$offset=0;
|
|
include('/path/to/config/.tidysearch.php');
|
|
/*
|
|
Keep your configs outside of server dirrector for security,
|
|
use a read only user to access the database in this case, $dbro[array]
|
|
*/
|
|
$con=pg_connect("host=".$dbro['host']." dbname=tidysearch user=".$dbro['user']." password=".$dbro['passw']);
|
|
$sql="SELECT idex FROM tidysearch.pages ORDER BY pages.idex DESC LIMIT 1;";
|
|
$row=pg_fetch_array(pg_query($con,$sql));
|
|
$pagesindexed=$row['idex'];
|
|
if (isset($_GET['pp'])){
|
|
$pp=$_GET['pp'];
|
|
if (!ctype_digit($pp) or $pp>(round($pagesindexed/10,0,PHP_ROUND_HALF_DOWN)+1) or $pp<0){
|
|
echo "<B>".$pp."</B><BR>";
|
|
header("Refresh:0; url=/bot_trap/?pp=".$pp);
|
|
exit;
|
|
}
|
|
}else{$pp=1;}
|
|
if (isset($_GET['qq'])){
|
|
$quary=$qq=trim($_GET['qq']);
|
|
// $quary=strtolower($qq);
|
|
// $quary=trim(htmlentities($quary,ENT_QUOTES|ENT_HTML5,'UTF-8',true));
|
|
}
|
|
$pages=paging('/',$pp,$pagesindexed,$qq,$offset);
|
|
$sql="SELECT * FROM tidysearch.sites WHERE sites.hits>0;";
|
|
$ret=pg_query($con,$sql);
|
|
while($row=pg_fetch_array($ret)){if (isset($row['hits'])){$THits=$THits+$row['hits'];}}
|
|
$Websites=pg_num_rows(pg_query($con,$sql));
|
|
$SITE="TidySearch";
|
|
$keywords="Fediverse, Decentralized, Federated, Search, Engine, MPAQ, ".$SITE."";
|
|
$desc="Decentralized Search Engine by MPAQ like the Fediverse AKA ActivityPub AKA Mastodon and XMPP. ".$SITE." has indexed ".$Websites." websites.";
|
|
$site_addy="http://search.mpaq.org";
|
|
$title=$SITE." Indexed Websites: ".$Websites;
|
|
unset($sql,$res);
|
|
$found=0;
|
|
echo "<!DOCTYPE html>
|
|
<html lang='en-US'>
|
|
<HEAD>
|
|
<META charSet='utf-8'>
|
|
<!-- <META name='color-scheme' content='light dark'> -->
|
|
<META name='viewport' content='width=device-width, initial-scale=1, user-scalable=1 , viewport-fit=auto'>
|
|
<META http-equiv='content-language' CONTENT='en-us'>
|
|
<META http-equiv='Content-Type' CONTENT='text/html; charset=UTF-8'>
|
|
<META http-equiv='Default-Style' CONTENT='desktop'>
|
|
<META NAME='robots' content='index, nofollow, noarchive'>
|
|
<LINK rel='stylesheet' href='TS.css'>
|
|
<META property='og:type' CONTENT='website'>
|
|
<META name='keywords' content='".$keywords."'>
|
|
<META name='description' content='".$desc."'>
|
|
<META NAME='author' CONTENT='".$SITE." All Copy Rights reserved by MPAQ © 2020-".date('Y')."'>
|
|
<LINK rel='shortcut icon' href='".$site_addy."/TSLogo.jpg' type='image/x-icon'>
|
|
<LINK rel='icon' href='".$site_addy."/TSLogo.jpg' type='image/x-icon'>
|
|
<LINK rel='apple-touch-icon' sizes='120x120' href='".$site_addy."/TSLogo.jpg' type='image/x-icon'>
|
|
<LINK rel='apple-touch-icon' sizes='152x152' href='".$site_addy."/TSLogo.jpg' type='image/x-icon'>
|
|
<META NAME='fediverse:creator' content='@bob@beamship.mpaq.org'>
|
|
<META property='og:title' content='".$title."'>
|
|
<META property='og:description' content='".$desc."'>
|
|
<META property='og:updated_time' content='".$UPD."T".$UPT."Z'>
|
|
<meta property='site_name' content='".$title."'>
|
|
<META property='og:url' CONTENT='".$site_addy."'>
|
|
<META property='og:image' content='".$site_addy."/TSLogo.jpg'>
|
|
<META NAME='twitter:site' content='".$title."'>
|
|
<META NAME='twitter:label1' content='".$title."'>
|
|
<META NAME='twitter:data1' content='".$title."'>
|
|
<META NAME=”twitter:title” content='".$title."'>
|
|
<META NAME=”twitter:card” content='website'>
|
|
<META NAME='twitter:description' CONTENT='".$desc."'>
|
|
<META NAME='twitter:url' CONTENT='".$site_addy."'>
|
|
<META NAME='twitter:image' CONTENT='".$site_addy."/TSLogo.jpg'>
|
|
<META itemprop='title' CONTENT='".$title."'>
|
|
<META itemprop='name' CONTENT='".$SITE."'>
|
|
<META itemprop='description' CONTENT='".$desc."'>
|
|
<META itemprop='url' CONTENT='".$site_addy."'>
|
|
<META itemprop='image' CONTENT='".$site_addy."/TSLogo.jpg'>
|
|
<TITLE>".$SITE."</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<CENTER>
|
|
<TABLE BORDER='0' WIDTH='99%' VALIGN='middle'>
|
|
<TR>
|
|
<TD ALIGN='left' WIDTH='15%' VALIGN='vertical-align:top'>
|
|
<abbr title='Dig as much as you can, we do not have garbage here :-)'><A HREF='/'><IMG SRC='TSLogo.jpg' STYLE='max-width: 70px;max-height: 70px;border: 0px solid #000000;' ALT='Dig as much as you can, we do not have garbage here :-)' loading='eager'></A></abbr><BR>";
|
|
?>
|
|
</TD>
|
|
<TD ALIGN='center' WIDTH='*' VALIGN='vertical-align:middle'>
|
|
<form action='/' id='qq' name='qq' method='get'>
|
|
<input type='text' placeholder='What are you looking for?' name='qq' CLASS='search'>
|
|
<input id='search' name='' type='submit' value='Search'></form>
|
|
<button onclick="location='/'">Clear</button> <button onclick="location='/books'">Books</button> <button onclick="location='/feed'">RSS Feed</button>
|
|
<BR><?PHP echo $pages[0];?>
|
|
</TD>
|
|
</TR>
|
|
</TABLE>
|
|
</CENTER>
|
|
<?PHP
|
|
if (is_null($quary)){
|
|
if (isset($pp)){$offset=$pp*10;}
|
|
$sql="SELECT * FROM ".$dbro['database'].".pages WHERE date IS NOT NULL ORDER BY pages.date DESC, pages.idex DESC LIMIT 10 OFFSET ".$offset.";";
|
|
$ret=pg_query($con,$sql);
|
|
while($row=pg_fetch_array($ret)){
|
|
$data=(array) null;
|
|
$data['Star']=NULL;
|
|
$data['PageID']=$row['idex'];
|
|
$data['KWords']=$row['kwords'];
|
|
$data['SiteID']=$row['site_id'];
|
|
$data['date']=$row['date'];
|
|
$data['title']=$row['title'];
|
|
$data['description']=$row['description'];
|
|
$data['link']=$row['source_code'];
|
|
$data['BotID']=$row['botid'];
|
|
$data['lan_code']=$row['lan_code'];
|
|
$data['HostID']=$row['hostid'];
|
|
$aa="SELECT * FROM ".$dbro['database'].".sites WHERE sites.index=".$data['SiteID'].";";
|
|
$ab=pg_fetch_array(pg_query($con,$aa));
|
|
$data['SiteName']=$ab['name'];
|
|
$data['lang']=lang($ab['_lang']);
|
|
$tmp1=html_entity_decode($data['title'],ENT_QUOTES|ENT_HTML5,'UTF-8')."\n";
|
|
$tmp1=trim(str_ireplace(' ','%20',$tmp1));
|
|
$tmp1=str_ireplace('\'',''',$tmp1);
|
|
$tmp2=substr($data['description'],0,500)."...";
|
|
$tmp2=html_entity_decode($tmp2,ENT_QUOTES|ENT_HTML5,'UTF-8')."\n";
|
|
$tmp2=trim(str_ireplace(' ','%20',$tmp2));
|
|
$tmp2=str_ireplace('\'',''',$tmp2);
|
|
if (isset($tmp1) and isset($data['link'])){
|
|
/*
|
|
This is a share button for the Fediverse and can be found at:
|
|
https://github.com/ArmandPhilippot/mastodon-sharing-button but seems to not be active
|
|
If needed, disable/comment out this secton
|
|
*/
|
|
$data['share']="
|
|
<abbr title='Share to the Fediverse'>
|
|
<A HREF='/share/select-instance.php?title=".$tmp1."&desc=".$tmp2."&url=".$data['link']."' TARGET='_blank'>
|
|
<IMG SRC='share/masto.gif' ALT='Share to the Fediverse'>
|
|
</A>
|
|
</abbr>
|
|
";
|
|
$found++;
|
|
}else{$data['share']=NULL;}
|
|
display($data);unset($tmp1,$tmp2,$data);
|
|
memory_get_usage();
|
|
}
|
|
}else{
|
|
/* Database searching takes place here but still needs work */
|
|
$LINE=0;
|
|
if (isset($pp)){$offset=$pp*10;}else{$offset=0;}
|
|
$sql="select * from tidysearch.pages where kwords ilike '% ".$quary." %' ORDER BY pages.date DESC, pages.idex DESC LIMIT 10 OFFSET ".$offset.";";
|
|
$test=pg_fetch_array(pg_query($con,$sql));
|
|
if ($test==false){
|
|
$sql="select * from tidysearch.pages where kwords ilike '%".$quary." %' ORDER BY pages.date DESC, pages.idex DESC LIMIT 10 OFFSET ".$offset.";";
|
|
$test=pg_fetch_array(pg_query($con,$sql));
|
|
$LINE=__LINE__;
|
|
}
|
|
if ($test==false){
|
|
$sql="select * from tidysearch.pages where kwords ilike '% ".$quary."%' ORDER BY pages.date DESC, pages.idex DESC LIMIT 10 OFFSET ".$offset.";";
|
|
$test=pg_fetch_array(pg_query($con,$sql));
|
|
$LINE=__LINE__;
|
|
}
|
|
if ($test==false){
|
|
$sql="select * from tidysearch.pages where kwords ilike '%".$quary."%' ORDER BY pages.date DESC, pages.idex DESC LIMIT 10 OFFSET ".$offset.";";
|
|
$test=pg_fetch_array(pg_query($con,$sql));
|
|
$LINE=__LINE__;
|
|
}
|
|
if ($test==false){
|
|
$sql="select * from tidysearch.pages where title ilike '%".$quary."%' ORDER BY pages.date DESC, pages.idex DESC LIMIT 10 OFFSET ".$offset.";";
|
|
$test=pg_fetch_array(pg_query($con,$sql));
|
|
$LINE=__LINE__;
|
|
}
|
|
if ($test==false){
|
|
$sql="select * from tidysearch.pages where description ilike '%".$quary."%' ORDER BY pages.date DESC, pages.idex DESC LIMIT 10 OFFSET ".$offset.";";
|
|
$test=pg_query($con,$sql);
|
|
$test=pg_fetch_array(pg_query($con,$sql));
|
|
$LINE=__LINE__;
|
|
}
|
|
if ($test==true){
|
|
$ret=pg_query($con,$sql);
|
|
}else{
|
|
echo "<CENTER><H1>Nothing found</H1></CENTER>";exit;
|
|
}
|
|
while($row=pg_fetch_array($ret)){
|
|
$data=(array) null;
|
|
$data['Star']=NULL;
|
|
$data['PageID']=$row['idex'];
|
|
$data['KWords']=$row['kwords'];
|
|
$data['SiteID']=$row['site_id'];
|
|
$data['date']=$row['date'];
|
|
$data['title']=$row['title'];
|
|
$data['description']=$row['description'];
|
|
$data['link']=$row['source_code'];
|
|
$data['BotID']=$row['botid'];
|
|
$data['lan_code']=$row['lan_code'];
|
|
$data['HostID']=$row['hostid'];
|
|
$aa="SELECT * FROM ".$db['database'].".sites WHERE sites.index=".$data['SiteID'].";";
|
|
$ab=pg_fetch_array(pg_query($con,$aa));
|
|
$data['SiteName']=$ab['name'];
|
|
$data['lang']=lang($ab['_lang']);
|
|
$tmp1=html_entity_decode($data['title'],ENT_QUOTES|ENT_HTML5,'UTF-8')."\n";
|
|
$tmp1=trim(str_ireplace(' ','%20',$tmp1));
|
|
$tmp1=str_ireplace('\'',''',$tmp1);
|
|
$tmp2=substr($data['description'],0,500)."...";
|
|
$tmp2=html_entity_decode($tmp2,ENT_QUOTES|ENT_HTML5,'UTF-8')."\n";
|
|
$tmp2=trim(str_ireplace(' ','%20',$tmp2));
|
|
$tmp2=str_ireplace('\'',''',$tmp2);
|
|
if (isset($tmp1) and isset($data['link'])){
|
|
/*
|
|
This is a share button for the Fediverse and can be found at:
|
|
https://github.com/ArmandPhilippot/mastodon-sharing-button but seems to not be active
|
|
If needed, disable/comment out this secton
|
|
*/
|
|
$data['share']="
|
|
<abbr title='Share to the Fediverse'>
|
|
<A HREF='/share/select-instance.php?title=".$tmp1."&desc=".$tmp2."&url=".$data['link']."' TARGET='_blank'>
|
|
<IMG SRC='share/masto.gif' ALT='Share to the Fediverse'>
|
|
</A>
|
|
</abbr>
|
|
";
|
|
$found++;
|
|
}else{$data['share']=NULL;}
|
|
$data['title']=highlightStr($data['title'],$quary,"blue");
|
|
$data['description']=highlightStr($data['description'],$quary,"red");
|
|
display($data);unset($tmp1,$tmp2,$data);
|
|
memory_get_usage();
|
|
}
|
|
}
|
|
$botZero="<BR>Help us <B><A HREF='https://212.102.59.80:250/keys.php' rel='noindex, nofollow' STYLE='color:blue;'>#TakeTheInternetBack</A></B>,<BR>join the TidySearch network.<BR>TidySearch has indexed <B>".number_format($pagesindexed)."</B> pages.";
|
|
echo " <CENTER>".$pages[0]."
|
|
<BR>
|
|
<BR>
|
|
<FONT SIZE='-2'>
|
|
<B>TidySearch ".$version."</B><BR>
|
|
All Copy Rights reserved by MPAQ © 2020-".date('Y')."<BR>
|
|
</FONT>
|
|
<FONT SIZE='-1'>
|
|
".$botZero."<BR><BR>
|
|
<A HREF='/tos.html' TARGET='_blank' STYLE='color: red;'>ToS</A> :
|
|
<A HREF='/about.php' TARGET='_blank' STYLE='color: blue;'>About ".$SITE."</A><BR>
|
|
<A HREF='/mpaq.html' TARGET='_blank' STYLE='color: red;'>About MPAQ</A> :
|
|
<A HREF='/team/9' TARGET='_blank' STYLE='color: blue;'>About the Author</A> :
|
|
<A HREF='/staff.php' TARGET='_blank' STYLE='color: red;'>MPAQ Team</A><BR>
|
|
</FONT>
|
|
</CENTER>
|
|
";
|
|
memory_get_usage(); /* Fource PHP cache cleanup */
|
|
?>
|
|
</BODY>
|
|
</HTML>
|