From 733d6aa8e5b6b9199a2308e62cf0496e7b71203f Mon Sep 17 00:00:00 2001
From: ztk <support@ztk.me>
Date: Tue, 13 Nov 2018 01:08:31 +0100
Subject: [PATCH] remove unnecessary db_connect calls / replaced by including
 lib/datenbank.inc.php

---
 adminforce/frametest.php | 7 +++----
 cron.php                 | 3 +--
 crons/db_backup.php      | 5 ++---
 index.php                | 2 --
 pcheck.php               | 5 +----
 pclick.php               | 4 +---
 pl.php                   | 5 ++---
 7 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/adminforce/frametest.php b/adminforce/frametest.php
index 7a6bafe..e24cf66 100644
--- a/adminforce/frametest.php
+++ b/adminforce/frametest.php
@@ -7,8 +7,8 @@ if ($_GET['testen'] == 'true') {
     if ($_GET['frame'] == 'true') {
         echo 'Dies ist der Testframe';
     } else {
-        @require_once ('../lib/functions.lib.php');
-        @db_connect();
+        require_once ( '../lib/datenbank.inc.php' );
+        require_once ( '../lib/functions.lib.php' );
         if (!isset($_GET['art'])) $_GET['art'] = "";
         if (!isset($forced['tan'])) $forced['tan'] = "";
         if (!isset($forced['ziel'])) $forced['ziel'] = "";
@@ -35,7 +35,6 @@ if ($_GET['testen'] == 'true') {
 </frameset><noframes></noframes><noframes>Bei dir sind keine Frames aktiviert!</noframes>
 </body>
 </html>';
-        db_close();
     }
 } else {
     echo 'Javascript Test! Bitte warte einen Moment!
@@ -44,4 +43,4 @@ if ($_GET['testen'] == 'true') {
     document.location = "frametest.php?url=' . $_GET['url'] . '&testen=true&tan=' . $_GET['tan'] . '";
     //-->
     </script>';
-}
\ No newline at end of file
+}
diff --git a/cron.php b/cron.php
index 1014c9e..fe488aa 100644
--- a/cron.php
+++ b/cron.php
@@ -4,7 +4,7 @@
 
 require ( 'lib/datenbank.inc.php' );
 require ( 'lib/functions.lib.php' );
-db_connect();
+
 if ($_GET['pw'] != $cron_pw) die('Zugriff verweigert!');
 
 $cron = (int)$_GET['id'];
@@ -34,4 +34,3 @@ if ( include ($result['datei']) ){
 	echo 'Cron gelaufen';
 } else echo 'Cron nicht gelaufen';
 
-db_close();
\ No newline at end of file
diff --git a/crons/db_backup.php b/crons/db_backup.php
index e44f250..21b4b09 100644
--- a/crons/db_backup.php
+++ b/crons/db_backup.php
@@ -2,7 +2,7 @@
  
 require('../lib/datenbank.inc.php');
 require('../lib/functions.lib.php');
-db_connect();
+
 if($_GET['cron_pw'] == $cron_pw){
 	set_time_limit(0);
 
@@ -27,5 +27,4 @@ if($_GET['cron_pw'] == $cron_pw){
 	mysqli_close($sql_open);
 	die();
 }
-db_close();
-?>
\ No newline at end of file
+?>
diff --git a/index.php b/index.php
index 983d01d..7b29ad3 100644
--- a/index.php
+++ b/index.php
@@ -14,7 +14,6 @@ if (!ini_get('display_errors')) {
 }
 
 require ('lib/datenbank.inc.php');
-db_connect();
 require ('lib/functions.lib.php');
 require ('lib/session.lib.php');
 require ('lib/run.inc.php');
@@ -202,6 +201,5 @@ $ts = strtotime($datetime);
     </body>
 </html>
 <?php
-db_close();
 if ($gzip_rate > 0) ob_end_flush();
 ?>
diff --git a/pcheck.php b/pcheck.php
index 4991660..b454f56 100644
--- a/pcheck.php
+++ b/pcheck.php
@@ -1,4 +1,5 @@
 <?php
+require ( 'lib/datenbank.inc.php' );
 require_once ('lib/functions.lib.php');
 
 //Variablen vordefinieren
@@ -10,9 +11,6 @@ if (!isset($_GET['auszahlen']))	       $_GET['auszahlen']	= "false";
 $_GET['uid'] = (int)$_GET['uid'];
 $_GET['tan'] = addslashes ($_GET['tan']);
 
-//DB Verbindung herstellen
-db_connect();
-
 $mail =  mysqli_fetch_assoc(db_query("SELECT e.start,e.aufendhalt,e.status,e.uid,v.verdienst FROM ".$db_prefix."_paidmails_empfaenger e
                                                                               LEFT JOIN ".$db_prefix."_paidmails_versendet v ON v.tan = e.tan
                                                                               WHERE e.tan='".$_GET['tan']."' AND e.uid=".$_GET['uid']." AND e.gueltig > ".time()." LIMIT 1"));
@@ -61,4 +59,3 @@ echo '
         </table>
     </body>
 </html>';
-db_close();
\ No newline at end of file
diff --git a/pclick.php b/pclick.php
index 5dfc5a3..169f5b4 100644
--- a/pclick.php
+++ b/pclick.php
@@ -1,6 +1,6 @@
 <?php
+require ( 'lib/datenbank.inc.php' );
 require_once ('lib/functions.lib.php');
-db_connect();
 
 $_GET['uid'] = (int)$_GET['uid'];
 $_GET['tan'] = addslashes ($_GET['tan']);
@@ -18,5 +18,3 @@ echo '
             <frame name="werbung" src="'.$mail['ziel'].'" scrolling="auto" frameborder="0">
         </frameset>
 </html>';
-
-db_close();
diff --git a/pl.php b/pl.php
index 910a2ed..055a067 100644
--- a/pl.php
+++ b/pl.php
@@ -1,6 +1,6 @@
-<?
+<?php
+require_once ( 'lib/datenbank.inc.php' );
 @require_once ('lib/functions.lib.php');
-@db_connect();
 @require_once ('lib/session.lib.php');
 if (!isset($_GET['art']))		$_GET['art']		= "";
 if (!isset($text['tan']))		$text['tan']		= "";
@@ -21,4 +21,3 @@ $text = mysqli_fetch_array(db_query("SELECT * FROM ".$db_prefix."_gebuchte_werbu
 </frameset>
 </body>
 </html>
-<?db_close();?>
-- 
GitLab