Sie sind hier : basti1012.de/ Kurze-Scripte-und-Codeschnipsel / index.php

Zurück


Der Quellcode dazu


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php

if(!isset($_SESSION)){ 
        
session_start(); 
        
$log=true;
    } else{
        
$log=false;
}

error_reporting(E_ALL); 
ini_set('display_errors'true);
$passwort='admin';
$admin='admin';
$file='besucherzaehler.txt';
if(!
file_exists($file)){
               
$current file_get_contents($file);
               
$inhalt"0";
               
file_put_contents($file$inhalt);
}else{
               
$inhalt file_get_contents($file);
}


if(!empty(
$_SESSION['counteradmin'])){
 if(
$_SESSION['counteradmin']==$admin){
    echo 
"Du bist eingeloggt als $_SESSION[counteradmin]<br>";
    
$log=true;
 }
}else{
    
$log=false;
}
 
if(isset(
$_POST['send'])){
      if(
$_POST['admin']==$admin && $_POST['pass']==$passwort || $log=='$true'){
          
$_SESSION['counteradmin']=$_POST['admin'];
          
$log=true;
      }else{
           echo 
"Name oder Passwort falsch";
      }
}     
         
if(isset(
$_POST['send1'])){       
          if(!
file_exists($file)){
               
$current file_get_contents($file);
               
$inhalt"0";
               
file_put_contents($file$inhalt);
          }else{
               
$current file_get_contents($file);
               
$inhalt$current 1;
               
file_put_contents($file$inhalt);
          }
}
?>


<!DOCTYPE html>
<html lang="de">
<head>                                          
    <title>Counter mit admin log</title>
    
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>itel</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-122955144-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-122955144-1');
</script>
<style>
*{
margin:0;
padding:0;
}
#basti1012{
position:absolute;
bottom:10px;
left:calc(50% - 50px);
text-align:center;
font-size:12px;
color:blue;
width:100px;
}
body {
  color: #2c3e50;
  background: #ecf0f1;
  text-align:center;
}
#counter{
  margin:40px;
  font-size:80px;
}

</style>
</head>
<body>
<?php
if($log==false){
?>
<form method="POST">
<span>Logge dich ein um den Counter zu erhöhen</span><br>
<input type="text" placeholder="Adminname..." name="admin"> ( admin )<br>
<input type="text" placeholder="Passwort..." name="pass">( admin )<br>
<input  type="submit" name="send" value="einloggen">
</form>
<?php
}else{
?>
<form method="POST">
<span> Jeder klick erhöht den Counter um ein</span><br>
<input id="hoch" type="submit" name="send1" value="Erhöhe um 1+"><br>
</form>
<?php
}
?>
<span id="counter"><?php echo $inhalt?></span>
<script>

 
$('*').click(function(){

//alert(this);
  
})

</script>

 
</body>
</head>