Migrate translations to gettext
This commit is contained in:
111
www/admin.php
111
www/admin.php
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
require_once(__DIR__.'/../common_config.php');
|
||||
global $language, $dir;
|
||||
$style = '.row{display:flex;flex-wrap:wrap}.headerrow{font-weight:bold}.col{display:flex;flex:1;padding:3px 3px;flex-direction:column}.button_table{max-width:500px}';
|
||||
$style .= '.list{padding:0;}.list li{display:inline-block;padding:0.35em}#maintable .col{min-width:5em}#maintable .col:first-child{max-width:5em}';
|
||||
$style .= '.red{color:red}.green{color:green}.software-link{text-align:center;font-size:small}#maintable,#maintable .col{border: 1px solid black}';
|
||||
@ -8,19 +9,19 @@ try{
|
||||
$db=new PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME . ';charset=utf8mb4', DBUSER, DBPASS, [PDO::ATTR_ERRMODE=>PDO::ERRMODE_WARNING, PDO::ATTR_PERSISTENT=>PERSISTENT]);
|
||||
}catch(PDOException $e){
|
||||
http_response_code(500);
|
||||
die($I['nodb']);
|
||||
die(_('No database connection!'));
|
||||
}
|
||||
asort($categories);
|
||||
?>
|
||||
<!DOCTYPE html><html lang="<?php echo $language; ?>"><head>
|
||||
<title><?php echo $I['admintitle']; ?></title>
|
||||
<!DOCTYPE html><html lang="<?php echo $language; ?>" dir="<?php echo $dir; ?>"><head>
|
||||
<title><?php echo _('Admin interface'); ?></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name=viewport content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex">
|
||||
<link rel="canonical" href="<?php echo CANONICAL_URL . $_SERVER['SCRIPT_NAME']; ?>">
|
||||
<style type="text/css"><?php echo $style; ?></style>
|
||||
<style><?php echo $style; ?></style>
|
||||
</head><body><main>
|
||||
<h1><?php echo $I['admintitle']; ?></h1>
|
||||
<h1><?php echo _('Admin interface'); ?></h1>
|
||||
<?php
|
||||
print_langs();
|
||||
|
||||
@ -28,11 +29,11 @@ print_langs();
|
||||
if(!isset($_POST['pass']) || $_POST['pass']!==ADMINPASS){
|
||||
echo "<form action=\"$_SERVER[SCRIPT_NAME]\" method=\"POST\">";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"$language\">";
|
||||
echo "<p><label>$I[password]: <input type=\"password\" name=\"pass\" size=\"30\" required autocomplete=\"current-password\"></label></p>";
|
||||
echo "<input type=\"submit\" name=\"action\" value=\"$I[login]\">";
|
||||
echo "<p><label>"._('Password:')." <input type=\"password\" name=\"pass\" size=\"30\" required autocomplete=\"current-password\"></label></p>";
|
||||
echo "<input type=\"submit\" name=\"action\" value=\""._('Login')."\">";
|
||||
echo '</form>';
|
||||
if(isset($_POST['pass'])){
|
||||
echo "<p class=\"red\" role=\"alert\">$I[wrongpass]</p>";
|
||||
echo "<p class=\"red\" role=\"alert\">"._('Wrong Password!')."</p>";
|
||||
}
|
||||
}else{
|
||||
$msg = '';
|
||||
@ -44,23 +45,23 @@ if(!isset($_POST['pass']) || $_POST['pass']!==ADMINPASS){
|
||||
$addrs = is_array($_POST['addr']) ? $_POST['addr'] : [$_POST['addr']];
|
||||
foreach ($addrs as $addr_single) {
|
||||
if ( ! preg_match( '~(^(https?://)?([a-z2-7]{55}d)(\.onion(/.*)?)?$)~i', trim( $addr_single ), $addr ) ) {
|
||||
$msg .= "<p class=\"red\" role=\"alert\">$I[invalonion]</p>";
|
||||
$msg .= "<p class=\"red\" role=\"alert\">"._('Invalid onion address!')."</p>";
|
||||
} else {
|
||||
$addr = strtolower( $addr[ 3 ] );
|
||||
$md5 = md5( $addr, true );
|
||||
if ( $_POST[ 'action' ] === $I[ 'remove' ] ) { //remove address from public display
|
||||
if ( $_POST[ 'action' ] === _('Remove') ) { //remove address from public display
|
||||
$db->prepare( 'UPDATE ' . PREFIX . "onions SET address='', locked=1, approved=-1, timechanged=? WHERE md5sum=?;" )->execute( [ time(), $md5 ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succremove]</p>";
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'lock' ] ) { //lock editing
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully removed onion address!')."</p>";
|
||||
} elseif ( $_POST[ 'action' ] === _('Lock') ) { //lock editing
|
||||
$db->prepare( 'UPDATE ' . PREFIX . 'onions SET locked=1, approved=1, timechanged=? WHERE md5sum=?;' )->execute( [ time(), $md5 ] );
|
||||
$msg .= "<p class=\"green\"> role=\"alert\"$I[succlock]</p>";
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'readd' ] ) { //add onion back, if previously removed
|
||||
$msg .= "<p class=\"green\"> role=\"alert\">"._('Successfully locked onion address!')."</p>";
|
||||
} elseif ( $_POST[ 'action' ] === _('Re-add') ) { //add onion back, if previously removed
|
||||
$db->prepare( 'UPDATE ' . PREFIX . 'onions SET address=?, locked=1, approved=1, timechanged=? WHERE md5sum=?;' )->execute( [ $addr, time(), $md5 ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succreadd]</p>";
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'unlock' ] ) { //unlock editing
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully re-added onion address!')."</p>";
|
||||
} elseif ( $_POST[ 'action' ] === _('Unlock') ) { //unlock editing
|
||||
$db->prepare( 'UPDATE ' . PREFIX . 'onions SET locked=0, approved=1, timechanged=? WHERE md5sum=?;' )->execute( [ time(), $md5 ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succunlock]</p>";
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'promote' ] ) { //promote link for payed time
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully unlocked onion address!')."</p>";
|
||||
} elseif ( $_POST[ 'action' ] === _('Promote') ) { //promote link for paid time
|
||||
$stmt = $db->prepare( 'SELECT special FROM ' . PREFIX . 'onions WHERE md5sum=?;' );
|
||||
$stmt->execute( [ $md5 ] );
|
||||
$specialtime = $stmt->fetch( PDO::FETCH_NUM );
|
||||
@ -70,11 +71,11 @@ if(!isset($_POST['pass']) || $_POST['pass']!==ADMINPASS){
|
||||
$time = $specialtime[ 0 ] + ( ( $_POST[ 'btc' ] / PROMOTEPRICE ) * PROMOTETIME );
|
||||
}
|
||||
$db->prepare( 'UPDATE ' . PREFIX . 'onions SET special=?, locked=1, approved=1, timechanged=? WHERE md5sum=?;' )->execute( [ $time, time(), $md5 ] );
|
||||
$msg .= sprintf( "<p class=\"green\" role=\"alert\">$I[succpromote]</p>", date( 'Y-m-d H:i', $time ) );
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'unpromote' ] ) { //remove promoted status
|
||||
$msg .= "<p class=\"green\" role=\"alert\">".sprintf(_('Successfully promoted onion address until %1$s!'), date( 'Y-m-d H:i', $time ))."</p>";
|
||||
} elseif ( $_POST[ 'action' ] === _('Un-promote') ) { //remove promoted status
|
||||
$db->prepare( 'UPDATE ' . PREFIX . 'onions SET special=0, timechanged=? WHERE md5sum=?;' )->execute( [ time(), $md5 ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succunpromote]</p>";
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'update' ] ) { //update description
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully un-promoted onion address!')."</p>";
|
||||
} elseif ( $_POST[ 'action' ] === _('Update') ) { //update description
|
||||
$stmt = $db->prepare( 'SELECT * FROM ' . PREFIX . 'onions WHERE md5sum=?;' );
|
||||
$stmt->execute( [ $md5 ] );
|
||||
if ( $category === count( $categories ) ) {
|
||||
@ -90,21 +91,21 @@ if(!isset($_POST['pass']) || $_POST['pass']!==ADMINPASS){
|
||||
if ( ! $stmt->fetch( PDO::FETCH_ASSOC ) ) { //not yet there, add it
|
||||
$stmt = $db->prepare( 'INSERT INTO ' . PREFIX . 'onions (address, description, md5sum, category, timeadded, locked, approved, timechanged) VALUES (?, ?, ?, ?, ?, 1, 1, ?);' );
|
||||
$stmt->execute( [ $addr, $desc, $md5, $category, time(), time() ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succadd]</p>";
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully added onion address!')."</p>";
|
||||
} elseif ( $desc != '' ) { //update description+category
|
||||
$stmt = $db->prepare( 'UPDATE ' . PREFIX . 'onions SET description=?, category=?, locked=1, approved=1, timechanged=? WHERE md5sum=?;' );
|
||||
$stmt->execute( [ $desc, $category, time(), $md5 ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succupddesc]</p>";
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully updated description!')."</p>";
|
||||
} elseif ( $category != 0 ) { //only update category
|
||||
$stmt = $db->prepare( 'UPDATE ' . PREFIX . 'onions SET category=?, locked=1, approved=1, timechanged=? WHERE md5sum=?;' );
|
||||
$stmt->execute( [ $category, time(), $md5 ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succupdcat]!</p>";
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully updated category!')."</p>";
|
||||
} else { //no description or category change and already known
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[alreadyknown]</p>";
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Thanks, but I already knew this address!')."</p>";
|
||||
}
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'phishing' ] ) {//mark as phishing clone
|
||||
} elseif ( $_POST[ 'action' ] === _('Phishing') ) {//mark as phishing clone
|
||||
if ( $_POST[ 'original' ] !== '' && ! preg_match( '~(^(https?://)?([a-z2-7]{55}d)(\.onion(/.*)?)?$)~i', $_POST[ 'original' ], $orig ) ) {
|
||||
$msg .= "<p class=\"red\" role=\"alert\">$I[invalonion]</p>";
|
||||
$msg .= "<p class=\"red\" role=\"alert\">"._('Invalid onion address!')."</p>";
|
||||
} else {
|
||||
if ( isset( $orig[ 3 ] ) ) {
|
||||
$orig = strtolower( $orig[ 3 ] );
|
||||
@ -116,30 +117,30 @@ if(!isset($_POST['pass']) || $_POST['pass']!==ADMINPASS){
|
||||
$stmt->execute( [ $addr, $orig ] );
|
||||
$stmt = $db->prepare( 'UPDATE ' . PREFIX . 'onions SET locked=1, approved=1, timechanged=? WHERE address=?;' );
|
||||
$stmt->execute( [ time(), $addr ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succaddphish]</p>";
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully added Phishing clone!')."</p>";
|
||||
} else {
|
||||
$msg .= "<p class=\"red\" role=\"alert\">$I[samephish]</p>";
|
||||
$msg .= "<p class=\"red\" role=\"alert\">"._('Not added Phishing clone! Phishing and original have the same address.')."</p>";
|
||||
}
|
||||
}
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'unphishing' ] ) { //remove phishing clone status
|
||||
} elseif ( $_POST[ 'action' ] === _('No phishing') ) { //remove phishing clone status
|
||||
$stmt = $db->prepare( 'DELETE FROM ' . PREFIX . 'phishing WHERE onion_id=(SELECT id FROM ' . PREFIX . 'onions WHERE address=?);' );
|
||||
$stmt->execute( [ $addr ] );
|
||||
$stmt = $db->prepare( 'UPDATE ' . PREFIX . 'onions SET locked=1, approved=1, timechanged=? WHERE address=?;' );
|
||||
$stmt->execute( [ time(), $addr ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succrmphish]</p>";
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'reject' ] ) { //lock editing
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully removed Phishing clone!')."</p>";
|
||||
} elseif ( $_POST[ 'action' ] === _('Reject') ) { //lock editing
|
||||
$db->prepare( 'UPDATE ' . PREFIX . 'onions SET approved=-1, timechanged=? WHERE md5sum=?;' )->execute( [ time(), $md5 ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succreject]</p>";
|
||||
} elseif ( $_POST[ 'action' ] === $I[ 'approve' ] ) { //lock editing
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully rejected onion address')."</p>";
|
||||
} elseif ( $_POST[ 'action' ] === _('Approve') ) { //lock editing
|
||||
$db->prepare( 'UPDATE ' . PREFIX . 'onions SET approved=1, timechanged=? WHERE md5sum=?;' )->execute( [ time(), $md5 ] );
|
||||
$msg .= "<p class=\"green\" role=\"alert\">$I[succapprove]</p>";
|
||||
$msg .= "<p class=\"green\" role=\"alert\">"._('Successfully approved onion address')."</p>";
|
||||
} else { //no specific button was pressed
|
||||
$msg .= "<p class=\"red\" role=\"alert\">$I[noaction]</p>";
|
||||
$msg .= "<p class=\"red\" role=\"alert\">"._('No action taken!')."</p>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$view_mode = isset($_POST['view_mode']) ? $_POST['view_mode'] : 'single';
|
||||
$view_mode = $_POST[ 'view_mode' ] ?? 'single';
|
||||
if(isset($_POST['switch_view_mode'])){
|
||||
$view_mode = $view_mode === 'single' ? 'multi' : 'single';
|
||||
}
|
||||
@ -147,13 +148,13 @@ if(!isset($_POST['pass']) || $_POST['pass']!==ADMINPASS){
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"$language\">";
|
||||
echo "<input type=\"hidden\" name=\"pass\" value=\"$_POST[pass]\">";
|
||||
echo "<input type=\"hidden\" name=\"view_mode\" value=\"$view_mode\">";
|
||||
echo "<br><input type=\"submit\" name=\"switch_view_mode\" value=\"$I[switchviewmode]\"></form>";
|
||||
echo "<br><input type=\"submit\" name=\"switch_view_mode\" value=\""._('Switch view mode')."\"></form>";
|
||||
echo "<form action=\"$_SERVER[SCRIPT_NAME]\" method=\"POST\">";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"$language\">";
|
||||
echo "<input type=\"hidden\" name=\"pass\" value=\"$_POST[pass]\">";
|
||||
echo "<input type=\"hidden\" name=\"view_mode\" value=\"$view_mode\">";
|
||||
if($view_mode === 'single') {
|
||||
echo "<p><label>$I[link]: <input name=\"addr\" size=\"30\" value=\"";
|
||||
echo "<p><label>"._('Onion link:')." <input name=\"addr\" size=\"30\" value=\"";
|
||||
if ( isset( $_REQUEST[ 'addr' ] ) ) {
|
||||
echo htmlspecialchars( $_REQUEST[ 'addr' ] );
|
||||
}
|
||||
@ -167,17 +168,17 @@ if(!isset($_POST['pass']) || $_POST['pass']!==ADMINPASS){
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
echo "<p><label>$I[cloneof]: <input type=\"text\" name=\"original\" size=\"30\"";
|
||||
echo "<p><label>"._('Clone of:')." <input type=\"text\" name=\"original\" size=\"30\"";
|
||||
if(isset($_REQUEST['original'])){
|
||||
echo ' value="'.htmlspecialchars($_REQUEST['original']).'"';
|
||||
}
|
||||
echo '></label></p>';
|
||||
echo "<p><label>$I[bitcoins]: <input type=\"text\" name=\"btc\" size=\"30\"";
|
||||
echo "<p><label>"._('Bitcoins:')." <input type=\"text\" name=\"btc\" size=\"30\"";
|
||||
if(isset($_REQUEST['btc'])){
|
||||
echo ' value="'.htmlspecialchars($_REQUEST['btc']).'"';
|
||||
}
|
||||
echo '></label></p>';
|
||||
echo "<p><label for=\"desc\">$I[adddesc]:</label> <br><textarea id=\"desc\" name=\"desc\" rows=\"2\" cols=\"30\">";
|
||||
echo "<p><label for=\"desc\">"._('Description:')."</label> <br><textarea id=\"desc\" name=\"desc\" rows=\"2\" cols=\"30\">";
|
||||
if(!empty($_REQUEST['desc'])){
|
||||
echo htmlspecialchars(trim($_REQUEST['desc']));
|
||||
}elseif(isset($_REQUEST['addr']) && is_string($_REQUEST['addr'])){
|
||||
@ -193,7 +194,7 @@ if(!isset($_POST['pass']) || $_POST['pass']!==ADMINPASS){
|
||||
}
|
||||
}
|
||||
echo '</textarea></p>';
|
||||
echo "<p><label>$I[category]: <select name=\"cat\">";
|
||||
echo "<p><label>"._('Category:')." <select name=\"cat\">";
|
||||
foreach($categories as $cat=>$name){
|
||||
echo "<option value=\"$cat\"";
|
||||
if($category==$cat || ($cat===0 && $category>=count($categories))){
|
||||
@ -204,20 +205,20 @@ if(!isset($_POST['pass']) || $_POST['pass']!==ADMINPASS){
|
||||
echo '</select></label></p>';
|
||||
echo '<input type="submit" name="action" value="None" hidden>';
|
||||
echo '<div class="table button_table"><div class="row">';
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[remove]\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[lock]\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[promote]\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[phishing]\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Remove')."\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Lock')."\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Promote')."\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Phishing')."\"></div>";
|
||||
echo '</div><div class="row">';
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[readd]\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[unlock]\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[unpromote]\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[unphishing]\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Re-add')."\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Unlock')."\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Un-promote')."\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('No phishing')."\"></div>";
|
||||
echo '</div><div class="row">';
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[update]\"></div>";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Update')."\"></div>";
|
||||
if(REQUIRE_APPROVAL) {
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[reject]\"></div class=\"col\">";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\"$I[approve]\"></div class=\"col\">";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Reject')."\"></div class=\"col\">";
|
||||
echo "<div class=\"col\"><input type=\"submit\" name=\"action\" value=\""._('Approve')."\"></div class=\"col\">";
|
||||
}
|
||||
echo '</div></div>';
|
||||
echo '</form><br>';
|
||||
|
141
www/onions.php
141
www/onions.php
@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Onion Link List - Main listing script
|
||||
*
|
||||
* Copyright (C) 2016-2020 Daniel Winzen <daniel@danwin1210.me>
|
||||
* Copyright (C) 2016-2020 Daniel Winzen <daniel@danwin1210.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -39,8 +39,9 @@ if(!isset($_REQUEST['format'])){
|
||||
send_html();
|
||||
}
|
||||
|
||||
function send_html(){
|
||||
global $I, $categories, $db, $language;
|
||||
function send_html(): void
|
||||
{
|
||||
global $categories, $db, $language, $dir;
|
||||
$numrows = 0;
|
||||
$style = '.row{display:flex;flex-wrap:wrap}.headerrow{font-weight:bold}.col{display:flex;flex:1;padding:3px 3px;flex-direction:column}';
|
||||
$style .= '.red{color:red}.green{color:green}.up .col:nth-child(0n+3),.up .col:nth-child(0n+4){background-color:#aaff88}.down .col:nth-child(0n+3),.down .col:nth-child(0n+4){background-color:#ff4444}';
|
||||
@ -51,9 +52,9 @@ function send_html(){
|
||||
asort($categories);
|
||||
//sql for special categories
|
||||
$special=[
|
||||
$I['all_legitimate']=>"address!='' AND category!=15 AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800',
|
||||
$I['lastadded']=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing)',
|
||||
$I['offline']=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff>604800'
|
||||
_('All legitimate')=>"address!='' AND category!=15 AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800',
|
||||
_('Last added')=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing)',
|
||||
_('Offline > 1 week')=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff>604800'
|
||||
];
|
||||
$canonical_query = [];
|
||||
if(isset($_REQUEST['cat'])) {
|
||||
@ -62,9 +63,6 @@ function send_html(){
|
||||
if(isset($_REQUEST['pg'])) {
|
||||
$canonical_query['pg'] = $_REQUEST['pg'];
|
||||
}
|
||||
if(!empty($_REQUEST['lang'])) {
|
||||
$canonical_query['lang'] = $_REQUEST['lang'];
|
||||
}
|
||||
if(!isset($_REQUEST['pg'])){
|
||||
$_REQUEST['pg']=1;
|
||||
}else{
|
||||
@ -89,7 +87,7 @@ function send_html(){
|
||||
$cat=count($categories);
|
||||
if($db instanceof PDO) {
|
||||
foreach ( $special as $name => $query ) {
|
||||
if ( $name === $I[ 'lastadded' ] ) {
|
||||
if ( $name === _('Last added') ) {
|
||||
$category_count[ $cat ] = PER_PAGE;
|
||||
} else {
|
||||
$category_count[ $cat ] = $db->query( 'SELECT COUNT(*) FROM ' . PREFIX . "onions WHERE $admin_approval $query;" )->fetch( PDO::FETCH_NUM )[ 0 ];
|
||||
@ -117,31 +115,31 @@ function send_html(){
|
||||
http_response_code( 404 );
|
||||
}
|
||||
}
|
||||
echo '<!DOCTYPE html><html lang="'.$language.'"><head>';
|
||||
echo "<title>$I[title]</title>";
|
||||
echo '<!DOCTYPE html><html lang="'.$language.'" dir="'.$dir.'"><head>';
|
||||
echo "<title>"._('Onion link list')."</title>";
|
||||
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
|
||||
echo '<meta name="author" content="Daniel Winzen">';
|
||||
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
|
||||
echo '<meta name="description" content="Huge link list of Tor hidden service onions. All the darknet links you need in one place.">';
|
||||
echo '<link rel="canonical" href="' . CANONICAL_URL . $_SERVER['SCRIPT_NAME'] . (empty($canonical_query) ? '' : '?' . http_build_query($canonical_query)) . '">';
|
||||
echo '<style type="text/css">'.$style.'</style>';
|
||||
echo '<style>'.$style.'</style>';
|
||||
echo '<base target="_blank">';
|
||||
echo '</head><body><main>';
|
||||
echo "<h1>$I[title]</h1>";
|
||||
echo "<h1>"._('Onion link list')."</h1>";
|
||||
if(!isset($db)){
|
||||
send_error("<b>$I[error]:</b> $I[nodb]");
|
||||
send_error(_('Error: No database connection!'));
|
||||
}
|
||||
echo '<p>I\'m not responsible for any content of websites linked here. 99% of darkweb sites selling anything are scams. Be careful and use your brain. Every week I get 2-5 E-Mails from people that were desperate to make money and fell for scammers, don\'t be one of them!</p>';
|
||||
//update onions description form
|
||||
echo "<div class=\"table\" id=\"edit-search\"><div class=\"row\"><div class=\"col\"><form action=\"$_SERVER[SCRIPT_NAME]\" target=\"_self\" method=\"POST\">";
|
||||
echo "<input type=\"hidden\" name=\"pg\" value=\"$_REQUEST[newpg]\">";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"$language\">";
|
||||
echo "<p><label>$I[addonion]: <br><input name=\"addr\" size=\"30\" placeholder=\"http://$_SERVER[HTTP_HOST]\" value=\"";
|
||||
echo "<p><label>"._('Onion address:')." <br><input name=\"addr\" size=\"30\" placeholder=\"http://$_SERVER[HTTP_HOST]\" value=\"";
|
||||
if(isset($_REQUEST['addr'])){
|
||||
echo htmlspecialchars($_REQUEST['addr']);
|
||||
}
|
||||
echo '" required></label></p>';
|
||||
echo "<p><label>$I[adddesc]: <br><textarea name=\"desc\" rows=\"2\" cols=\"30\">";
|
||||
echo "<p><label>"._('Description:')." <br><textarea name=\"desc\" rows=\"2\" cols=\"30\">";
|
||||
if(!empty($_REQUEST['desc'])){//use posted description
|
||||
echo htmlspecialchars(trim($_REQUEST['desc']));
|
||||
}elseif(!empty($_REQUEST['addr'])){//fetch description from database
|
||||
@ -156,7 +154,7 @@ function send_html(){
|
||||
}
|
||||
}
|
||||
echo '</textarea></label></p>';
|
||||
echo "<p><label>$I[category]: <select name=\"cat\">";
|
||||
echo "<p><label>"._('Category:')." <select name=\"cat\">";
|
||||
foreach($categories as $cat=>$name){
|
||||
echo "<option value=\"$cat\"";
|
||||
if($category==$cat || ($cat===0 && $category>=count($categories))){
|
||||
@ -166,22 +164,22 @@ function send_html(){
|
||||
}
|
||||
echo '</select></label></p>';
|
||||
send_captcha();
|
||||
echo "<input type=\"submit\" name=\"action\" value=\"$I[update]\"></form></div>";
|
||||
echo "<input type=\"submit\" name=\"action\" value=\""._('Update')."\"></form></div>";
|
||||
//search from
|
||||
echo "<div class=\"col\"><form action=\"$_SERVER[SCRIPT_NAME]\" target=\"_self\" method=\"post\">";
|
||||
echo "<input type=\"hidden\" name=\"pg\" value=\"$_REQUEST[newpg]\">";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"$language\">";
|
||||
echo "<p><label>$I[search]: <br><input name=\"q\" size=\"30\" placeholder=\"$I[searchterm]\" value=\"";
|
||||
echo "<p><label>"._('Search:')." <br><input name=\"q\" size=\"30\" placeholder=\""._('Search term')."\" value=\"";
|
||||
if(isset($_REQUEST['q'])){
|
||||
echo trim(str_replace(['http://', 'https://', '.onion', '/'], '', htmlspecialchars($_REQUEST['q'])));
|
||||
}
|
||||
echo '"></label></p>';
|
||||
echo "<p><label>$I[category]: <select name=\"cat\">";
|
||||
echo "<p><label>"._('Category:')." <select name=\"cat\">";
|
||||
echo '<option value="'.count($categories).'"';
|
||||
if($category>=count($categories)){
|
||||
echo ' selected';
|
||||
}
|
||||
echo ">$I[all]</option>";
|
||||
echo ">"._('All')."</option>";
|
||||
foreach($categories as $cat=>$name){
|
||||
echo "<option value=\"$cat\"";
|
||||
if($category==$cat){
|
||||
@ -194,13 +192,13 @@ function send_html(){
|
||||
if(isset($_REQUEST['hidelocked'])){
|
||||
echo ' checked';
|
||||
}
|
||||
echo ">$I[hidelocked]</label></p>";
|
||||
echo "<input type=\"submit\" name=\"action\" value=\"$I[search]\"></form></div>";
|
||||
echo ">"._('Hide locked')."</label></p>";
|
||||
echo "<input type=\"submit\" name=\"action\" value=\""._('Search')."\"></form></div>";
|
||||
echo '</div></div>';
|
||||
echo "<ul class=\"list\"><li>$I[format]:</li><li><a href=\"?format=text\" target=\"_self\">Text</a></li><li><a href=\"?format=json\" target=\"_self\">JSON</a></li></ul>";
|
||||
echo "<ul class=\"list\"><li>"._('Format:')."</li><li><a href=\"?format=text\" target=\"_self\">Text</a></li><li><a href=\"?format=json\" target=\"_self\">JSON</a></li></ul>";
|
||||
print_langs();
|
||||
//List special categories
|
||||
echo "<ul class=\"list\"><li>$I[specialcat]:</li>";
|
||||
echo "<ul class=\"list\"><li>"._('Special categories:')."</li>";
|
||||
$cat=count($categories);
|
||||
foreach($special as $name=>$query){
|
||||
if($category==$cat){
|
||||
@ -211,18 +209,18 @@ function send_html(){
|
||||
++$cat;
|
||||
}
|
||||
if($category==$cat){
|
||||
echo " <li class=\"active\"><a href=\"?cat=$cat&lang=$language\" target=\"_self\">$I[phishingclones] ($category_count[$cat])</a></li>";
|
||||
echo " <li class=\"active\"><a href=\"?cat=$cat&lang=$language\" target=\"_self\">"._('Phishing Clones')." ($category_count[$cat])</a></li>";
|
||||
}else{
|
||||
echo " <li><a href=\"?cat=$cat&lang=$language\" target=\"_self\">$I[phishingclones] ($category_count[$cat])</a></li>";
|
||||
echo " <li><a href=\"?cat=$cat&lang=$language\" target=\"_self\">"._('Phishing Clones')." ($category_count[$cat])</a></li>";
|
||||
}
|
||||
echo " <li>$I[removed] ($category_count[removed])</li>";
|
||||
echo " <li>"._('Removed/Child porn')." ($category_count[removed])</li>";
|
||||
if(REQUIRE_APPROVAL) {
|
||||
echo " <li>$I[pendingapproval] ($category_count[pending])</li>";
|
||||
echo " <li>$I[rejected] ($category_count[rejected])</li>";
|
||||
echo " <li>"._('Pending approval')." ($category_count[pending])</li>";
|
||||
echo " <li>"._('Rejected')." ($category_count[rejected])</li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
//List normal categories
|
||||
echo "<ul class=\"list\"><li>$I[categories]:</li>";
|
||||
echo "<ul class=\"list\"><li>"._('Categories:')."</li>";
|
||||
foreach($categories as $cat=>$name){
|
||||
if($category==$cat){
|
||||
echo " <li class=\"active\"><a href=\"?cat=$cat&pg=$_REQUEST[newpg]&lang=$language\" target=\"_self\">$name ($category_count[$cat])</a></li>";
|
||||
@ -233,24 +231,24 @@ function send_html(){
|
||||
echo '</ul>';
|
||||
if($_SERVER['REQUEST_METHOD']==='POST' && !empty($_REQUEST['addr'])){
|
||||
if(!preg_match('~(^(https?://)?([a-z0-9]*\.)?([a-z2-7]{55}d)(\.onion(/.*)?)?$)~i', trim($_REQUEST['addr']), $addr)){
|
||||
echo "<p class=\"red\" role=\"alert\">$I[invalonion]</p>";
|
||||
echo "<p>$I[valid]: http://tt3j2x4k5ycaa5zt.onion</p>";
|
||||
echo "<p class=\"red\" role=\"alert\">"._('Invalid onion address!')."</p>";
|
||||
echo "<p>"._('A valid address looks like this')." http://tt3j2x4k5ycaa5zt.onion</p>";
|
||||
}else{
|
||||
if(!isset($_REQUEST['challenge'])){
|
||||
send_error('Error: Wrong Captcha');
|
||||
send_error(_('Error: Wrong captcha'));
|
||||
}
|
||||
$stmt=$db->prepare('SELECT code FROM ' . PREFIX . 'captcha WHERE id=?;');
|
||||
$stmt->execute([$_REQUEST['challenge']]);
|
||||
$stmt->bindColumn(1, $code);
|
||||
if(!$stmt->fetch(PDO::FETCH_BOUND)){
|
||||
send_error('Error: Captcha expired');
|
||||
send_error(_('Error: Captcha expired'));
|
||||
}
|
||||
$time=time();
|
||||
$stmt=$db->prepare('DELETE FROM ' . PREFIX . 'captcha WHERE id=? OR time<?;');
|
||||
$stmt->execute([$_REQUEST['challenge'], $time-3600]);
|
||||
if($_REQUEST['captcha']!==$code){
|
||||
if(strrev($_REQUEST['captcha'])!==$code){
|
||||
send_error('Error: Wrong captcha');
|
||||
send_error(_('Error: Wrong captcha'));
|
||||
}
|
||||
}
|
||||
$addr=strtolower($addr[4]);
|
||||
@ -271,19 +269,19 @@ function send_html(){
|
||||
if(!$stmt->fetch(PDO::FETCH_BOUND)){//new link, add to database
|
||||
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'onions (address, description, md5sum, category, timeadded, timechanged) VALUES (?, ?, ?, ?, ?, ?);');
|
||||
$stmt->execute([$addr, $desc, $md5, $category, time(), time()]);
|
||||
echo "<p class=\"green\" role=\"alert\">$I[succadd]</p>";
|
||||
echo "<p class=\"green\" role=\"alert\">"._('Successfully added onion address!')."</p>";
|
||||
}elseif($locked==1){//locked, not editable
|
||||
echo "<p class=\"red\" role=\"alert\">$I[faillocked]</p>";
|
||||
echo "<p class=\"red\" role=\"alert\">"._('Sorry, editing this onion address has been locked!')."</p>";
|
||||
}elseif($desc!==''){//update description
|
||||
$stmt=$db->prepare('UPDATE ' . PREFIX . 'onions SET description=?, category=?, timechanged=? WHERE md5sum=?;');
|
||||
$stmt->execute([$desc, $category, time(), $md5]);
|
||||
echo "<p class=\"green\" role=\"alert\">$I[succupddesc]</p>";
|
||||
echo "<p class=\"green\" role=\"alert\">"._('Successfully updated description!')."</p>";
|
||||
}elseif($category!=0){//update category only
|
||||
$stmt=$db->prepare('UPDATE ' . PREFIX . 'onions SET category=?, timechanged=? WHERE md5sum=?;');
|
||||
$stmt->execute([$category, time(), $md5]);
|
||||
echo "<p class=\"green\" role=\"alert\">$I[succupdcat]</p>";
|
||||
echo "<p class=\"green\" role=\"alert\">"._('Successfully updated category!')."</p>";
|
||||
}else{//nothing changed and already known
|
||||
echo "<p class=\"green\" role=\"alert\">$I[alreadyknown]</p>";
|
||||
echo "<p class=\"green\" role=\"alert\">"._('Thanks, but I already knew this address!')."</p>";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -309,7 +307,7 @@ function send_html(){
|
||||
$stmt->execute([$category, $query, $query]);
|
||||
}
|
||||
$table=get_table($stmt, $numrows);
|
||||
printf("<p><b>$I[searchresult]</b></p>", trim(str_replace(['http://', 'https://', '.onion', '/'], '', htmlspecialchars($_REQUEST['q']))), $numrows);
|
||||
printf("<p><b>"._('Searching for "%1$s", %2$d results found:')."</b></p>", trim(str_replace(['http://', 'https://', '.onion', '/'], '', htmlspecialchars($_REQUEST['q']))), $numrows);
|
||||
echo $table;
|
||||
}elseif($category>=count($categories)+count($special)){//show phishing clones
|
||||
print_phishing_table();
|
||||
@ -349,14 +347,14 @@ function send_html(){
|
||||
}
|
||||
|
||||
function get_table(PDOStatement $stmt, int &$numrows = 0, bool $promoted = false) : string {
|
||||
global $I, $db, $language;
|
||||
global $db, $language;
|
||||
$time=time();
|
||||
$admin_approval = '';
|
||||
if(REQUIRE_APPROVAL){
|
||||
$admin_approval = PREFIX . 'onions.approved = 1 AND';
|
||||
}
|
||||
ob_start();
|
||||
echo "<div class=\"table\" id=\"maintable\"><div class=\"row headerrow\"><div class=\"col\">$I[link]</div><div class=\"col\">$I[description]</div><div class=\"col\">$I[lasttested]</div><div class=\"col\">$I[lastup]</div><div class=\"col\">$I[timeadded]</div><div class=\"col\">$I[actions]</div></div>";
|
||||
echo "<div class=\"table\" id=\"maintable\"><div class=\"row headerrow\"><div class=\"col\">"._('Onion link')."</div><div class=\"col\">"._('Description')."</div><div class=\"col\">"._('Last tested')."</div><div class=\"col\">"._('Last seen')."</div><div class=\"col\">"._('Added at')."</div><div class=\"col\">"._('Actions')."</div></div>";
|
||||
if($promoted){//print promoted links at the top
|
||||
$time=time();
|
||||
$promo=$db->prepare('SELECT address, lasttest, lastup, timeadded, description, locked, special FROM ' . PREFIX . "onions WHERE $admin_approval special>? AND address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800 ORDER BY address;');
|
||||
@ -368,17 +366,17 @@ function get_table(PDOStatement $stmt, int &$numrows = 0, bool $promoted = false
|
||||
$class='down';
|
||||
}
|
||||
if($link['lastup']==0){
|
||||
$lastup=$I['never'];
|
||||
$lastup=_('Never');
|
||||
}else{
|
||||
$lastup=date('Y-m-d H:i:s', $link['lastup']);
|
||||
}
|
||||
if($link['lasttest']==0){
|
||||
$lasttest=$I['never'];
|
||||
$lasttest=_('Never');
|
||||
}else{
|
||||
$lasttest=date('Y-m-d H:i:s', $link['lasttest']);
|
||||
}
|
||||
$timeadded=date('Y-m-d H:i:s', $link['timeadded']);
|
||||
echo "<div class=\"$class row promo\"><div class=\"col\"><a href=\"http://$link[address].onion\" rel=\"noopener\">$link[address].onion</a></div><div class=\"col\">$link[description]</div><div class=\"col\">$lasttest</div><div class=\"col\">$lastup</div><div class=\"col\">$timeadded</div><div class=\"col\"><form method=\"post\" action=\"test.php\"><input name=\"addr\" value=\"$link[address]\" type=\"hidden\"><input name=\"lang\" value=\"$language\" type=\"hidden\"><input value=\"$I[test]\" type=\"submit\"></form></div></div>";
|
||||
echo "<div class=\"$class row promo\"><div class=\"col\"><a href=\"http://$link[address].onion\" rel=\"noopener\">$link[address].onion</a></div><div class=\"col\">$link[description]</div><div class=\"col\">$lasttest</div><div class=\"col\">$lastup</div><div class=\"col\">$timeadded</div><div class=\"col\"><form method=\"post\" action=\"test.php\"><input name=\"addr\" value=\"$link[address]\" type=\"hidden\"><input name=\"lang\" value=\"$language\" type=\"hidden\"><input value=\""._('Test')."\" type=\"submit\"></form></div></div>";
|
||||
}
|
||||
}
|
||||
while($link=$stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
@ -388,12 +386,12 @@ function get_table(PDOStatement $stmt, int &$numrows = 0, bool $promoted = false
|
||||
$class='down';
|
||||
}
|
||||
if($link['lastup']==0){
|
||||
$lastup=$I['never'];
|
||||
$lastup=_('Never');
|
||||
}else{
|
||||
$lastup=date('Y-m-d H:i:s', $link['lastup']);
|
||||
}
|
||||
if($link['lasttest']==0){
|
||||
$lasttest=$I['never'];
|
||||
$lasttest=_('Never');
|
||||
$class='';
|
||||
}else{
|
||||
$lasttest=date('Y-m-d H:i:s', $link['lasttest']);
|
||||
@ -405,22 +403,23 @@ function get_table(PDOStatement $stmt, int &$numrows = 0, bool $promoted = false
|
||||
if($link['locked']==1){
|
||||
$edit='-';
|
||||
}else{
|
||||
$edit="<form><input name=\"addr\" value=\"$link[address]\" type=\"hidden\"><input type=\"hidden\" name=\"pg\" value=\"$_REQUEST[newpg]\"><input type=\"hidden\" name=\"lang\" value=\"$language\"><input value=\"$I[edit]\" type=\"submit\"></form>";
|
||||
$edit="<form><input name=\"addr\" value=\"$link[address]\" type=\"hidden\"><input type=\"hidden\" name=\"pg\" value=\"$_REQUEST[newpg]\"><input type=\"hidden\" name=\"lang\" value=\"$language\"><input value=\""._('Edit')."\" type=\"submit\"></form>";
|
||||
}
|
||||
echo "<div class=\"row $class\"><div class=\"col\"><a href=\"http://$link[address].onion\" rel=\"noopener\">$link[address].onion</a></div><div class=\"col\">$link[description]</div><div class=\"col\">$lasttest</div><div class=\"col\">$lastup</div><div class=\"col\">$timeadded</div><div class=\"col\">$edit <form method=\"post\" action=\"test.php\"><input name=\"addr\" value=\"$link[address]\" type=\"hidden\"><input type=\"hidden\" name=\"lang\" value=\"$language\"><input value=\"$I[test]\" type=\"submit\"></form></div></div>";
|
||||
echo "<div class=\"row $class\"><div class=\"col\"><a href=\"http://$link[address].onion\" rel=\"noopener\">$link[address].onion</a></div><div class=\"col\">$link[description]</div><div class=\"col\">$lasttest</div><div class=\"col\">$lastup</div><div class=\"col\">$timeadded</div><div class=\"col\">$edit <form method=\"post\" action=\"test.php\"><input name=\"addr\" value=\"$link[address]\" type=\"hidden\"><input type=\"hidden\" name=\"lang\" value=\"$language\"><input value=\""._('Test')."\" type=\"submit\"></form></div></div>";
|
||||
++$numrows;
|
||||
}
|
||||
echo '</div>';
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
function print_phishing_table(){
|
||||
global $I, $db;
|
||||
function print_phishing_table(): void
|
||||
{
|
||||
global $db;
|
||||
$admin_approval = '';
|
||||
if(REQUIRE_APPROVAL){
|
||||
$admin_approval = 'approved = 1 AND';
|
||||
}
|
||||
echo "<div class=\"table\" id=\"maintable\"><div class=\"row headerrow\"><div class=\"col\">$I[link]</div><div class=\"col\">$I[cloneof]</div><div class=\"col\">$I[lastup]</div></div>";
|
||||
echo "<div class=\"table\" id=\"maintable\"><div class=\"row headerrow\"><div class=\"col\">"._('Onion link')."</div><div class=\"col\">"._('Clone of')."</div><div class=\"col\">"._('Last seen')."</div></div>";
|
||||
$stmt=$db->query('SELECT address, original, lasttest, lastup FROM ' . PREFIX . 'onions, ' . PREFIX . 'phishing WHERE ' . "$admin_approval " . PREFIX . "onions.id=onion_id AND address!='' AND timediff<604800 ORDER BY address;");
|
||||
while($link=$stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
if($link['lastup']===$link['lasttest']){
|
||||
@ -429,24 +428,25 @@ function print_phishing_table(){
|
||||
$class='down';
|
||||
}
|
||||
if($link['lastup']==0){
|
||||
$lastup=$I['never'];
|
||||
$lastup=_('Never');
|
||||
}else{
|
||||
$lastup=date('Y-m-d H:i:s', $link['lastup']);
|
||||
}
|
||||
if($link['original']!==''){
|
||||
$orig="<a href=\"http://$link[original].onion\" rel=\"noopener\">$link[original].onion</a>";
|
||||
}else{
|
||||
$orig=$I['unknown'];
|
||||
$orig=_('Unknown');
|
||||
}
|
||||
echo "<div class=\"row $class\"><div class=\"col\">$link[address].onion</div><div class=\"col\">$orig</div><div class=\"col\">$lastup</div></div>";
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function send_text(){
|
||||
global $I, $db;
|
||||
function send_text(): void
|
||||
{
|
||||
global $db;
|
||||
if(!isset($db)){
|
||||
die("$I[error]: $I[nodb]");
|
||||
die(_('Error: No database connection!'));
|
||||
}
|
||||
header('Content-Type: text/plain; charset=UTF-8');
|
||||
$admin_approval = '';
|
||||
@ -459,10 +459,11 @@ function send_text(){
|
||||
}
|
||||
}
|
||||
|
||||
function send_json(){
|
||||
global $I, $db, $categories;
|
||||
function send_json(): void
|
||||
{
|
||||
global $db, $categories;
|
||||
if(!isset($db)){
|
||||
die("$I[error]: $I[nodb]");
|
||||
die(_('Error: No database connection!'));
|
||||
}
|
||||
header('Content-Type: application/json;');
|
||||
$admin_approval = '';
|
||||
@ -482,13 +483,13 @@ function send_json(){
|
||||
}
|
||||
|
||||
function get_pagination(int $category, int $pages) : string {
|
||||
global $I, $language;
|
||||
global $language;
|
||||
ob_start();
|
||||
echo "<ul class=\"list pagination\"><li>$I[pages]:</li>";
|
||||
echo "<ul class=\"list pagination\"><li>"._('Pages:')."</li>";
|
||||
if($_REQUEST['pg']==0){
|
||||
echo " <li class=\"active\"><a href=\"?cat=$category&pg=0&lang=$language\" target=\"_self\">$I[all]</a></li>";
|
||||
echo " <li class=\"active\"><a href=\"?cat=$category&pg=0&lang=$language\" target=\"_self\">"._('All')."</a></li>";
|
||||
}else{
|
||||
echo " <li><a href=\"?cat=$category&pg=0&lang=$language\" target=\"_self\">$I[all]</a></li>";
|
||||
echo " <li><a href=\"?cat=$category&pg=0&lang=$language\" target=\"_self\">"._('All')."</a></li>";
|
||||
}
|
||||
for($i=1; $i<=$pages; ++$i){
|
||||
if($_REQUEST['pg']==$i){
|
||||
@ -501,7 +502,8 @@ function get_pagination(int $category, int $pages) : string {
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
function send_captcha(){
|
||||
function send_captcha(): void
|
||||
{
|
||||
global $db;
|
||||
$difficulty=1;
|
||||
if($difficulty===0 || !extension_loaded('gd')){
|
||||
@ -548,6 +550,7 @@ function send_captcha(){
|
||||
echo "<input type=\"hidden\" name=\"challenge\" value=\"$randid\"><input type=\"text\" name=\"captcha\" size=\"15\" autocomplete=\"off\"></label></p>";
|
||||
}
|
||||
|
||||
function send_error(string $msg){
|
||||
function send_error(string $msg): void
|
||||
{
|
||||
die("<p class=\"red\" role=\"alert\">$msg</p></main></body></html>");
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ try{
|
||||
$db=new PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME . ';charset=utf8mb4', DBUSER, DBPASS, [PDO::ATTR_ERRMODE=>PDO::ERRMODE_WARNING, PDO::ATTR_PERSISTENT=>PERSISTENT]);
|
||||
}catch(PDOException $e){
|
||||
http_response_code(500);
|
||||
die($I['nodb']);
|
||||
die(_('No database connection!'));
|
||||
}
|
||||
$links = [];
|
||||
$links []= ['loc' => CANONICAL_URL . '/test.php', 'changefreq' => 'weekly', 'priority' => '0.8'];
|
||||
@ -15,7 +15,7 @@ $admin_approval = '';
|
||||
if(REQUIRE_APPROVAL){
|
||||
$admin_approval = PREFIX . 'onions.approved = 1 AND';
|
||||
}
|
||||
foreach ($L as $lang_code => $lang){
|
||||
foreach (LANGUAGES as $lang_code => $data){
|
||||
$links []= ['loc' => CANONICAL_URL . "/test.php?lang=$lang_code", 'changefreq' => 'weekly', 'priority' => '0.4'];
|
||||
$links []= ['loc' => CANONICAL_URL . "/onions.php?lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.5'];
|
||||
$stmt=$db->prepare('SELECT COUNT(*) FROM ' . PREFIX . "onions WHERE $admin_approval category=? AND address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800;');
|
||||
@ -32,12 +32,12 @@ foreach ($L as $lang_code => $lang){
|
||||
}
|
||||
}
|
||||
$special=[
|
||||
$I['all']=>"address!='' AND category!=15 AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800',
|
||||
$I['lastadded']=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing)',
|
||||
$I['offline']=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff>604800'
|
||||
'all'=>"address!='' AND category!=15 AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800',
|
||||
'lastadded'=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing)',
|
||||
'offline'=>"address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff>604800'
|
||||
];
|
||||
$cat=count($categories);
|
||||
foreach($special as $name=>$query){
|
||||
foreach($special as $query){
|
||||
$links []= ['loc' => CANONICAL_URL . "/onions.php?cat=$cat&lang=$lang_code", 'changefreq' => 'daily', 'priority' => '0.3'];
|
||||
if($cat===count($categories)+1){
|
||||
$num[0]=PER_PAGE;
|
||||
|
37
www/test.php
37
www/test.php
@ -1,33 +1,30 @@
|
||||
<?php
|
||||
require_once(__DIR__.'/../common_config.php');
|
||||
global $language, $dir;
|
||||
$style = '.red{color:red}.green{color:green}.software-link{text-align:center;font-size:small}.list{padding:0;}.list li{display:inline-block;padding:0.35em}';
|
||||
send_headers([$style]);
|
||||
$canonical_query = [];
|
||||
if(!empty($_REQUEST['lang'])) {
|
||||
$canonical_query['lang'] = $_REQUEST['lang'];
|
||||
}
|
||||
echo '<!DOCTYPE html><html lang="'.$language.'"><head>';
|
||||
echo "<title>$I[testtitle]</title>";
|
||||
echo '<!DOCTYPE html><html lang="'.$language.'" dir="'.$dir.'"><head>';
|
||||
echo "<title>"._('Online-Test')."</title>";
|
||||
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
|
||||
echo '<meta name="author" content="Daniel Winzen">';
|
||||
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
|
||||
echo '<meta name="description" content="Test whether a Tor hidden service onion is online or offline">';
|
||||
echo '<link rel="canonical" href="' . CANONICAL_URL . $_SERVER['SCRIPT_NAME'] . (empty($canonical_query) ? '' : '?' . http_build_query($canonical_query)) . '">';
|
||||
echo '<style type="text/css">'.$style.'</style>';
|
||||
echo '<link rel="canonical" href="' . CANONICAL_URL . $_SERVER['SCRIPT_NAME'] . '">';
|
||||
echo '<style>'.$style.'</style>';
|
||||
echo '</head><body><main>';
|
||||
echo "<h1>$I[testtitle]</h1>";
|
||||
echo "<h1>"._('Online-Test')."</h1>";
|
||||
print_langs();
|
||||
echo "<p>$I[testdesc]</p>";
|
||||
echo "<p>"._('Here an onion address can be tested, for whether it is online or not.')."</p>";
|
||||
echo "<form action=\"$_SERVER[SCRIPT_NAME]\" method=\"POST\">";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"$language\">";
|
||||
echo "<p><label for=\"addr\">$I[link]:</label><br><input id=\"addr\" name=\"addr\" size=\"30\" value=\"";
|
||||
echo "<p><label for=\"addr\">"._('Onion link:')."</label><br><input id=\"addr\" name=\"addr\" size=\"30\" value=\"";
|
||||
if(isset($_REQUEST['addr'])){
|
||||
echo htmlspecialchars($_REQUEST['addr']);
|
||||
}else{
|
||||
echo "http://$_SERVER[HTTP_HOST]";
|
||||
}
|
||||
echo '" required></p>';
|
||||
echo "<input type=\"submit\" name=\"action\" value=\"$I[test]\"></form><br>";
|
||||
echo "<input type=\"submit\" name=\"action\" value=\""._('Test')."\"></form><br>";
|
||||
if(!empty($_REQUEST['addr'])){
|
||||
if(ob_get_level()>0){
|
||||
ob_end_flush();
|
||||
@ -36,15 +33,15 @@ if(!empty($_REQUEST['addr'])){
|
||||
$db=new PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME . ';charset=utf8mb4', DBUSER, DBPASS, [PDO::ATTR_ERRMODE=>PDO::ERRMODE_WARNING, PDO::ATTR_PERSISTENT=>PERSISTENT]);
|
||||
}catch(PDOException $e){
|
||||
http_response_code(500);
|
||||
die($I['nodb']);
|
||||
die(_('No database connection!'));
|
||||
}
|
||||
if(!preg_match('~(^(https?://)?([a-z0-9]*\.)?([a-z2-7]{55}d)(\.onion(/.*)?)?$)~i', trim($_REQUEST['addr']), $addr)){
|
||||
echo "<p class=\"red\" role=\"alert\">$I[invalonion]</p>";
|
||||
echo "<p class=\"red\" role=\"alert\">"._('Invalid onion address!')."</p>";
|
||||
}else{
|
||||
$ch=curl_init();
|
||||
set_curl_options($ch);
|
||||
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_URL, "http://$addr[4].onion/");
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Host: $addr[4].onion", 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: en-US,en;q=0.5', 'Accept-Encoding: gzip, deflate', 'Connection: keep-alive', 'Upgrade-Insecure-Requests: 1']);
|
||||
@ -54,17 +51,17 @@ if(!empty($_REQUEST['addr'])){
|
||||
$phishing=$db->prepare('SELECT original FROM ' . PREFIX . 'phishing, ' . PREFIX . 'onions WHERE address=? AND onion_id=' . PREFIX . 'onions.id;');
|
||||
$phishing->execute([$addr]);
|
||||
if($orig=$phishing->fetch(PDO::FETCH_NUM)){
|
||||
printf("<p class=\"red\" role=\"alert\">$I[testphishing]</p>", "<a href=\"http://$orig[0].onion\">$orig[0].onion</a>");
|
||||
printf("<p class=\"red\" role=\"alert\">"._('Warning, this is a known phishing clone. The original site is located at %s.')."</p>", "<a href=\"http://$orig[0].onion\">$orig[0].onion</a>");
|
||||
}
|
||||
$scam=$db->prepare('SELECT null FROM ' . PREFIX . 'onions WHERE md5sum=? AND category=15 AND locked=1;');
|
||||
$scam->execute([$md5]);
|
||||
if($scam->fetch(PDO::FETCH_NUM)){
|
||||
echo "<p class=\"red\" role=\"alert\">Warning: This is a known scam!</p>";
|
||||
echo "<p class=\"red\" role=\"alert\">"._('Warning: This is a known scam!')."</p>";
|
||||
}
|
||||
$stmt=$db->prepare('SELECT null FROM ' . PREFIX . 'onions WHERE md5sum=? AND timediff=0 AND lasttest>?;');
|
||||
$stmt->execute([$md5, time()-60]);
|
||||
if($stmt->fetch(PDO::FETCH_NUM)){
|
||||
echo "<p class=\"green\" role=\"alert\">$I[testonline]</p>";
|
||||
echo "<p class=\"green\" role=\"alert\">"._('Yes, the service is online!')."</p>";
|
||||
}elseif(($content=curl_exec($ch))!==false){
|
||||
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
$header = substr($content, 0, $header_size);
|
||||
@ -99,13 +96,13 @@ if(!empty($_REQUEST['addr'])){
|
||||
}
|
||||
blacklist_scams($addr, $content);
|
||||
}
|
||||
echo "<p class=\"green\" role=\"alert\">$I[testonline]</p>";
|
||||
echo "<p class=\"green\" role=\"alert\">"._('Yes, the service is online!')."</p>";
|
||||
}else{
|
||||
if(isset($db)){
|
||||
$time=time();
|
||||
$db->prepare('UPDATE ' . PREFIX . 'onions SET lasttest=?, timediff=lasttest-lastup WHERE md5sum=? AND lasttest<?;')->execute([$time, $md5, $time]);
|
||||
}
|
||||
echo "<p class=\"red\" role=\"alert\">$I[testoffline]</p>";
|
||||
echo "<p class=\"red\" role=\"alert\">"._('No, the service is offline!')."</p>";
|
||||
}
|
||||
curl_close($ch);
|
||||
}
|
||||
|
Reference in New Issue
Block a user