Turn array() to [] and add timeadded to links submitted via onion.php

This commit is contained in:
Daniel Winzen
2016-09-29 08:07:16 +02:00
parent 2e8f51080c
commit 5d8b8daed8
6 changed files with 23 additions and 23 deletions

View File

@ -39,10 +39,10 @@ $categories=['Unsorted', 'Adult/Porn', 'Communication/Social', 'Cryptocurrencies
// Language selection
$L=array(
$L=[
'de' => 'Deutsch',
'en' => 'English',
);
];
if(isSet($_REQUEST['lang']) && isSet($L[$_REQUEST['lang']])){
$language=$_REQUEST['lang'];
if(!isSet($_COOKIE['language']) || $_COOKIE['language']!==$language){

View File

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$T=array(
$T=[
'all' => 'Alle',
'lastadded' => 'Zuletzt hinzugefügt',
'offline' => 'Offline > 1 Woche',
@ -93,5 +93,5 @@ $T=array(
'dateextrequired' => 'Die date Erweiterung von PHP wird benötigt. Bitte installieren Sie diese zuerst.',
'succdbcreate' => 'Die Datenbank wurde erfolgreich erstellt!',
'statusok' => 'Status: OK',
);
];
?>

View File

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$I=array(
$I=[
'all' => 'All',
'lastadded' => 'Last added',
'offline' => 'Offline > 1 week',
@ -93,5 +93,5 @@ $I=array(
'dateextrequired' => 'The date extension of PHP is required. Please install it first.',
'succdbcreate' => 'The database has successfully been created!',
'statusok' => 'Status: OK',
);
];
?>

View File

@ -25,7 +25,7 @@ echo "<?php
*/
//Native language name: $native
\$T=array(
\$T=[
";
if(file_exists("lang_$code.php")){
include("lang_$code.php");
@ -39,7 +39,7 @@ foreach($T as $id=>$value){
foreach($I as $id=>$value){
echo "\t'$id' => '".str_replace("'", "\'", $value)."',\n";
}
echo ");\n?>\n";
echo "];\n?>\n";
$file=ob_get_clean();
file_put_contents("lang_$code.php", $file);
?>

View File

@ -89,7 +89,7 @@ function send_html(){
$addr=strtolower($addr[4]);
$md5=md5($addr, true);
$stmt=$db->prepare('SELECT description, category FROM ' . PREFIX . 'onions WHERE md5sum=?;');
$stmt->execute(array($md5));
$stmt->execute([$md5]);
if($desc=$stmt->fetch(PDO::FETCH_ASSOC)){
$category=$desc['category'];
echo str_replace('<br>', "\n", $desc['description']);
@ -155,7 +155,7 @@ function send_html(){
echo "<ul class=\"list\"><li>$I[categories]:</li>";
$stmt=$db->prepare('SELECT COUNT(*) FROM ' . PREFIX . "onions WHERE category=? AND address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800;');
foreach($categories as $cat=>$name){
$stmt->execute(array($cat));
$stmt->execute([$cat]);
$num=$stmt->fetch(PDO::FETCH_NUM);
if($category==$cat){
echo " <li class=\"active\"><a href=\"?cat=$cat&amp;pg=$_REQUEST[newpg]&amp;lang=$language\">$name ($num[0])</a></li>";
@ -173,7 +173,7 @@ function send_html(){
$addr=strtolower($addr[4]);
$md5=md5($addr, true);
$stmt=$db->prepare('SELECT locked FROM ' . PREFIX . 'onions WHERE md5sum=?;');
$stmt->execute(array($md5));
$stmt->execute([$md5]);
$stmt->bindColumn(1, $locked);
if($category==count($categories)){
$category=0;
@ -186,18 +186,18 @@ function send_html(){
$desc=preg_replace("/(\r?\n|\r\n?)/", '<br>', $desc);
}
if(!$stmt->fetch(PDO::FETCH_BOUND)){//new link, add to database
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'onions (address, description, md5sum, category) VALUES (?, ?, ?, ?);');
$stmt->execute(array($addr, $desc, $md5, $category));
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'onions (address, description, md5sum, category, timeadded) VALUES (?, ?, ?, ?, ?);');
$stmt->execute([$addr, $desc, $md5, $category, time()]);
echo "<p class=\"green\">$I[succadd]</p>";
}elseif($locked==1){//locked, not editable
echo "<p class=\"red\">$I[faillocked]</p>";
}elseif($desc!==''){//update description
$stmt=$db->prepare('UPDATE ' . PREFIX . 'onions SET description=?, category=? WHERE md5sum=?;');
$stmt->execute(array($desc, $category, $md5));
$stmt->execute([$desc, $category, $md5]);
echo "<p class=\"green\">$I[succupddesc]</p>";
}elseif($category!=0){//update category only
$stmt=$db->prepare('UPDATE ' . PREFIX . 'onions SET category=? WHERE md5sum=?;');
$stmt->execute(array($category, $md5));
$stmt->execute([$category, $md5]);
echo "<p class=\"green\">$I[succupdcat]</p>";
}else{//nothing changed and already known
echo "<p class=\"green\">$I[alreadyknown]</p>";
@ -214,7 +214,7 @@ function send_html(){
$stmt=$db->prepare('SELECT address, lasttest, lastup, timeadded, description, locked, special FROM ' . PREFIX . "onions WHERE address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800 AND (description LIKE ? OR address LIKE ?) ORDER BY address;');
$query=htmlspecialchars($_REQUEST['q']);
$query="%$query%";
$stmt->execute(array($query, $query));
$stmt->execute([$query, $query]);
$table=get_table($stmt, $numrows);
printf("<p><b>$I[searchresult]</b></p>", $_REQUEST['q'], $numrows);
echo $table;
@ -245,7 +245,7 @@ function send_html(){
$offsetquery='';
}
$stmt=$db->prepare('SELECT address, lasttest, lastup, timeadded, description, locked, special FROM ' . PREFIX . "onions WHERE address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . "phishing) AND category=? AND timediff<604800 ORDER BY address$offsetquery;");
$stmt->execute(array($category));
$stmt->execute([$category]);
echo get_table($stmt, $numrows, true);
}
echo '<br>';
@ -262,7 +262,7 @@ function get_table(PDOStatement $stmt, &$numrows=0, $promoted=false){
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 special>? AND address!='' AND id NOT IN (SELECT onion_id FROM " . PREFIX . 'phishing) AND timediff<604800 ORDER BY address;');
$promo->execute(array($time));
$promo->execute([$time]);
while($link=$promo->fetch(PDO::FETCH_ASSOC)){
if($link['lastup']===$link['lasttest']){
$class='up';

View File

@ -66,7 +66,7 @@ if(!empty($_REQUEST['addr'])){
$md5=md5($addr, true);
//display warning, if a phishing clone was tested
$phishing=$db->prepare('SELECT original FROM ' . PREFIX . 'phishing, ' . PREFIX . 'onions WHERE address=? AND onion_id=' . PREFIX . 'onions.id;');
$phishing->execute(array($addr));
$phishing->execute([$addr]);
if($orig=$phishing->fetch(PDO::FETCH_NUM)){
printf("<p class=\"red\">$I[testphishing]</p>", "<a href=\"http://$orig[0].onion\">$orig[0].onion</a>");
}
@ -74,17 +74,17 @@ if(!empty($_REQUEST['addr'])){
if(isSet($db)){
//update entry in database
$stmt=$db->prepare('SELECT * FROM ' . PREFIX . 'onions WHERE md5sum=?;');
$stmt->execute(array($md5));
$stmt->execute([$md5]);
if(!$stmt->fetch(PDO::FETCH_NUM)){
$db->prepare('INSERT INTO ' . PREFIX . 'onions (address, md5sum, timeadded) VALUES (?, ?, ?);')->execute(array($addr, $md5, time()));
$db->prepare('INSERT INTO ' . PREFIX . 'onions (address, md5sum, timeadded) VALUES (?, ?, ?);')->execute([$addr, $md5, time()]);
}
$db->prepare('UPDATE ' . PREFIX . 'onions SET lasttest=?, lastup=lasttest, timediff=0 WHERE md5sum=?;')->execute(array(time(), $md5));
$db->prepare('UPDATE ' . PREFIX . 'onions SET lasttest=?, lastup=lasttest, timediff=0 WHERE md5sum=?;')->execute([time(), $md5]);
}
echo "<p class=\"green\">$I[testonline]</p>";
}else{
if(isSet($db)){
$time=time();
$db->prepare('UPDATE ' . PREFIX . 'onions SET lasttest=?, timediff=lasttest-lastup WHERE md5sum=? AND lasttest<?;')->execute(array($time, $md5, $time));
$db->prepare('UPDATE ' . PREFIX . 'onions SET lasttest=?, timediff=lasttest-lastup WHERE md5sum=? AND lasttest<?;')->execute([$time, $md5, $time]);
}
echo "<p class=\"red\">$I[testoffline]</p>";
}