Added a section to send recomended sites

Signed-off-by: Bob <bob@mpaq.org>
This commit is contained in:
Bob
2026-05-17 19:44:49 -07:00
parent aaf8277d39
commit 804d3fa326
+85 -23
View File
@@ -1,36 +1,41 @@
<?PHP <?PHP
ini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL); //ini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL);
$StartTime=date('H:i:s'); $StartTime=date('H:i:s');
$home_dir=__DIR__; $home_dir=__DIR__;
include_once('TSfun.php'); include_once('TSfun.php');
$UPD=date('Y-m-d');$UPT=date('H:i:s'); $UPD=date('Y-m-d');$UPT=date('H:i:s');
$qq=$quary=NULL;$THits=$offset=0; $qq=$quary=NULL;$THits=$offset=0;
include('/path/to/config/.tidysearch.php'); include('/media/10T/ADMIN/.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']); $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;"; $sql="SELECT idex FROM tidysearch.pages ORDER BY pages.idex DESC LIMIT 1;";
$row=pg_fetch_array(pg_query($con,$sql)); $row=pg_fetch_array(pg_query($con,$sql));
$pagesindexed=$row['idex']; $pagesindexed=$row['idex'];
$Tpages=0;
$aa="SELECT idex FROM tidysearch.pages ORDER BY pages.idex;";
$Tpages=pg_num_rows(pg_query($con,$aa));
if (isset($_GET['pp'])){ if (isset($_GET['pp'])){
$pp=$_GET['pp']; $pp=$_GET['pp'];
if (!ctype_digit($pp) or $pp>(round($pagesindexed/10,0,PHP_ROUND_HALF_DOWN)+1) or $pp<0){ if (!ctype_digit($pp) or $pp>(round($pagesindexed/10,0,PHP_ROUND_HALF_DOWN)+1) or $pp<0){
echo "<B>".$pp."</B><BR>"; echo "<B>".$pp."</B><BR>";
// $send="Line ".__LINE__." Possible DoS attack. ?pp=".$pp." from ".$_SERVER['HTTP_USER_AGENT'];
// send_group("TidyWeb","system@lobby.mpaq.org",$send,"mpaq.org");
header("Refresh:0; url=/bot_trap/?pp=".$pp); header("Refresh:0; url=/bot_trap/?pp=".$pp);
exit; exit;
} }
}else{$pp=1;} }else{$pp=1;}
if (isset($_GET['qq'])){ if (isset($_GET['qq'])){
$quary=$qq=trim($_GET['qq']); $quary=$qq=trim($_GET['qq']);
// $quary=strtolower($qq); $quary=trim(htmlentities($quary,ENT_QUOTES|ENT_HTML5,'UTF-8',true));
// $quary=trim(htmlentities($quary,ENT_QUOTES|ENT_HTML5,'UTF-8',true));
} }
$pages=paging('/',$pp,$pagesindexed,$qq,$offset); $pages=paging('/',$pp,$pagesindexed,$qq,$offset);
$sql="SELECT * FROM tidysearch.sites WHERE sites.hits>0;"; $sql="SELECT * FROM tidysearch.sites WHERE sites.hits>0;";
$ret=pg_query($con,$sql); $ret=pg_query($con,$sql);
while($row=pg_fetch_array($ret)){if (isset($row['hits'])){$THits=$THits+$row['hits'];}} while($row=pg_fetch_array($ret)){
if (isset($row['hits'])){
$THits=$THits+$row['hits'];
}
}
$Websites=pg_num_rows(pg_query($con,$sql)); $Websites=pg_num_rows(pg_query($con,$sql));
$SITE="TidySearch"; $SITE="TidySearch";
$keywords="Fediverse, Decentralized, Federated, Search, Engine, MPAQ, ".$SITE.""; $keywords="Fediverse, Decentralized, Federated, Search, Engine, MPAQ, ".$SITE."";
@@ -128,11 +133,6 @@ if (is_null($quary)){
$tmp2=trim(str_ireplace(' ','%20',$tmp2)); $tmp2=trim(str_ireplace(' ','%20',$tmp2));
$tmp2=str_ireplace('\'','&apos;',$tmp2); $tmp2=str_ireplace('\'','&apos;',$tmp2);
if (isset($tmp1) and isset($data['link'])){ 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']=" $data['share']="
<abbr title='Share to the Fediverse'> <abbr title='Share to the Fediverse'>
<A HREF='/share/select-instance.php?title=".$tmp1."&desc=".$tmp2."&url=".$data['link']."' TARGET='_blank'> <A HREF='/share/select-instance.php?title=".$tmp1."&desc=".$tmp2."&url=".$data['link']."' TARGET='_blank'>
@@ -142,11 +142,33 @@ If needed, disable/comment out this secton
"; ";
$found++; $found++;
}else{$data['share']=NULL;} }else{$data['share']=NULL;}
if ($_SERVER['SERVER_NAME']==="192.168.4.250" or $_SERVER['SERVER_NAME']==="localhost"){
if (!is_null($data['lan_code'])){
$Mcon=pg_connect("host=".$dbro['host']." dbname=movie_system user=".$dbro['user']." password=".$dbro['passw']);
$tmp=trim(str_ireplace('a/','',$data['lan_code']));
$aa="SELECT * FROM movie_system.active WHERE active.yts=".$tmp;
$ab=pg_fetch_array(pg_query($Mcon,$aa));
if (isset($ab['yts'])){
$data['Star']="
<abbr title='Go to the Media Center'>
<A HREF='https://192.168.6.250/".$data['lan_code']."' TARGET='_blank'>
<IMG SRC='/icons/red.jpg'>
</A>
</abbr>";
}else{
$data['Star']="
<abbr title='Go to the Media Center'>
<A HREF='https://192.168.6.250/".$data['lan_code']."' TARGET='_blank'>
<IMG SRC='/icons/black.jpg'>
</A>
</abbr>";
}
}
}
display($data);unset($tmp1,$tmp2,$data); display($data);unset($tmp1,$tmp2,$data);
memory_get_usage(); memory_get_usage();
} }
}else{ }else{
/* Database searching takes place here but still needs work */
$LINE=0; $LINE=0;
if (isset($pp)){$offset=$pp*10;}else{$offset=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.";"; $sql="select * from tidysearch.pages where kwords ilike '% ".$quary." %' ORDER BY pages.date DESC, pages.idex DESC LIMIT 10 OFFSET ".$offset.";";
@@ -178,6 +200,7 @@ $LINE=__LINE__;
$LINE=__LINE__; $LINE=__LINE__;
} }
if ($test==true){ if ($test==true){
//echo "Line: ".$LINE." <B>".$sql."</B><BR><BR>";
$ret=pg_query($con,$sql); $ret=pg_query($con,$sql);
}else{ }else{
echo "<CENTER><H1>Nothing found</H1></CENTER>";exit; echo "<CENTER><H1>Nothing found</H1></CENTER>";exit;
@@ -195,7 +218,7 @@ $LINE=__LINE__;
$data['BotID']=$row['botid']; $data['BotID']=$row['botid'];
$data['lan_code']=$row['lan_code']; $data['lan_code']=$row['lan_code'];
$data['HostID']=$row['hostid']; $data['HostID']=$row['hostid'];
$aa="SELECT * FROM ".$db['database'].".sites WHERE sites.index=".$data['SiteID'].";"; $aa="SELECT * FROM ".$dbro['database'].".sites WHERE sites.index=".$data['SiteID'].";";
$ab=pg_fetch_array(pg_query($con,$aa)); $ab=pg_fetch_array(pg_query($con,$aa));
$data['SiteName']=$ab['name']; $data['SiteName']=$ab['name'];
$data['lang']=lang($ab['_lang']); $data['lang']=lang($ab['_lang']);
@@ -207,11 +230,6 @@ $LINE=__LINE__;
$tmp2=trim(str_ireplace(' ','%20',$tmp2)); $tmp2=trim(str_ireplace(' ','%20',$tmp2));
$tmp2=str_ireplace('\'','&apos;',$tmp2); $tmp2=str_ireplace('\'','&apos;',$tmp2);
if (isset($tmp1) and isset($data['link'])){ 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']=" $data['share']="
<abbr title='Share to the Fediverse'> <abbr title='Share to the Fediverse'>
<A HREF='/share/select-instance.php?title=".$tmp1."&desc=".$tmp2."&url=".$data['link']."' TARGET='_blank'> <A HREF='/share/select-instance.php?title=".$tmp1."&desc=".$tmp2."&url=".$data['link']."' TARGET='_blank'>
@@ -221,13 +239,38 @@ If needed, disable/comment out this secton
"; ";
$found++; $found++;
}else{$data['share']=NULL;} }else{$data['share']=NULL;}
if ($_SERVER['SERVER_NAME']==="192.168.4.250" or $_SERVER['SERVER_NAME']==="localhost"){
if (!is_null($data['lan_code'])){
$Mcon=pg_connect("host=".$dbro['host']." dbname=movie_system user=".$dbro['user']." password=".$dbro['passw']);
$tmp=trim(str_ireplace('a/','',$data['lan_code']));
$aa="SELECT * FROM movie_system.active WHERE active.yts=".$tmp;
$ab=pg_fetch_array(pg_query($Mcon,$aa));
if (isset($ab['yts'])){
$data['Star']="
<abbr title='Go to the Media Center'>
<A HREF='https://192.168.6.250/".$data['lan_code']."' TARGET='_blank'>
<IMG SRC='/icons/red.jpg'>
</A>
</abbr>";
}else{
$data['Star']="
<abbr title='Go to the Media Center'>
<A HREF='https://192.168.6.250/".$data['lan_code']."' TARGET='_blank'>
<IMG SRC='/icons/black.jpg'>
</A>
</abbr>";
}
}
}
$data['title']=highlightStr($data['title'],$quary,"blue"); $data['title']=highlightStr($data['title'],$quary,"blue");
$data['description']=highlightStr($data['description'],$quary,"red"); $data['description']=highlightStr($data['description'],$quary,"red");
display($data);unset($tmp1,$tmp2,$data); display($data);unset($tmp1,$tmp2,$data);
memory_get_usage(); 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."; include('/media/10T/ADMIN/.TS_config_Web.php');
include('/media/10T/ADMIN/.tidysearch.php');
$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($Tpages)."</B> pages on <B>".number_format($Websites)."</B> sites.";
echo " <CENTER>".$pages[0]." echo " <CENTER>".$pages[0]."
<BR> <BR>
<BR> <BR>
@@ -243,9 +286,28 @@ echo " <CENTER>".$pages[0]."
<A HREF='/team/9' TARGET='_blank' STYLE='color: blue;'>About the Author</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> <A HREF='/staff.php' TARGET='_blank' STYLE='color: red;'>MPAQ Team</A><BR>
</FONT> </FONT>
<BR>
<TABLE BORDER='1' WIDTH='50%' VALIGN='middle'><TR><TD ALIGN='center' VALIGN='vertical-align:middle'>
Make a recommendation to our list.<BR>The more you can tell us,<BR>the easier it will be to include:
<FORM action='recommend.php' method='post' name='recommend' id='recommend' CLASS='fix'>
<input type='text' name='SiteName' id='SiteName' placeholder='Site Name, Required' size='25' required><BR>
<input type='text' placeholder='Site Address, Required' name='url' size='25' required><BR>
<input type='text' placeholder='RSS Feed, Optional' name='rss' size='25'><BR>
<input type='text' placeholder='Publised Language, Optional' name='lang' size='25'><BR>
<input type='text' placeholder='Your email, Optional' name='email' size='25'><BR>
<input type='submit' value='Recommend a site'>
</FORM>
</TD></TR></TABLE>
<BR>
</CENTER> </CENTER>
"; ";
memory_get_usage(); /* Fource PHP cache cleanup */ memory_get_usage();
if ($_SERVER['SERVER_NAME']==="192.168.4.250" or $_SERVER['SERVER_NAME']==="localhost"){
echo "<CENTER> Hits: ".$THits."<BR>".$sql."<BR>Mem: ".memory_get_usage()."<BR>Proc: ".time_check($StartTime)."</CENTER>";
}
// CREATE UNIQUE INDEX dex ON tidysearch.sites (index);
?> ?>
</BODY> </BODY>
</HTML> </HTML>