From 5d8b8daed8ba115dc4f069062610924953672581 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Thu, 29 Sep 2016 08:07:16 +0200 Subject: [PATCH] Turn array() to [] and add timeadded to links submitted via onion.php --- common_config.php | 4 ++-- lang_de.php | 4 ++-- lang_en.php | 4 ++-- lang_update.php | 4 ++-- onions.php | 20 ++++++++++---------- test.php | 10 +++++----- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/common_config.php b/common_config.php index 2ed71ed..649c728 100644 --- a/common_config.php +++ b/common_config.php @@ -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){ diff --git a/lang_de.php b/lang_de.php index ae39c38..bd92384 100644 --- a/lang_de.php +++ b/lang_de.php @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -$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', -); +]; ?> diff --git a/lang_en.php b/lang_en.php index d4dbd11..f618e23 100644 --- a/lang_en.php +++ b/lang_en.php @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -$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', -); +]; ?> diff --git a/lang_update.php b/lang_update.php index 11691f5..9c3fada 100644 --- a/lang_update.php +++ b/lang_update.php @@ -25,7 +25,7 @@ echo "$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); ?> diff --git a/onions.php b/onions.php index c76dd5a..330332f 100644 --- a/onions.php +++ b/onions.php @@ -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('
', "\n", $desc['description']); @@ -155,7 +155,7 @@ function send_html(){ echo "
  • $I[categories]:
  • "; $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 "
  • $name ($num[0])
  • "; @@ -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?)/", '
    ', $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 "

    $I[succadd]

    "; }elseif($locked==1){//locked, not editable echo "

    $I[faillocked]

    "; }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 "

    $I[succupddesc]

    "; }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 "

    $I[succupdcat]

    "; }else{//nothing changed and already known echo "

    $I[alreadyknown]

    "; @@ -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("

    $I[searchresult]

    ", $_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 '
    '; @@ -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'; diff --git a/test.php b/test.php index 976bcd9..ce33895 100644 --- a/test.php +++ b/test.php @@ -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("

    $I[testphishing]

    ", "$orig[0].onion"); } @@ -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 "

    $I[testonline]

    "; }else{ if(isSet($db)){ $time=time(); - $db->prepare('UPDATE ' . PREFIX . 'onions SET lasttest=?, timediff=lasttest-lastup WHERE md5sum=? AND lasttestexecute(array($time, $md5, $time)); + $db->prepare('UPDATE ' . PREFIX . 'onions SET lasttest=?, timediff=lasttest-lastup WHERE md5sum=? AND lasttestexecute([$time, $md5, $time]); } echo "

    $I[testoffline]

    "; }