summaryrefslogtreecommitdiff
path: root/www-ssl/admin/userSaveSecure.php
blob: 6eadeddcb475868794846037d08af6af37472425 (plain)
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
136
137
138
139
140
141
142
143
144
<?PHP

$title = "User-Liste";
$header = "Index";
include ("../../includes/header.php");
include ("../../includes/funktion_db_list.php");
include ("../../includes/crypt.php");
include ("../../includes/funktion_db.php");

if( !IsSet($_POST["enterUID"]) ) 
{
	$Right = "N";
} elseif( $_POST["enterUID"] > 0 ) {
	$Right = $_SESSION['CVS'][ "admin/user.php"];
} else {
	$Right = $_SESSION['CVS'][ "admin/group.php"];
}

if ( ($Right=="Y") && IsSet($_GET["action"])) 
{
	SetHeaderGo2Back();
	echo "Gesendeter Befehl: ". $_GET["action"]. "<br>";
	
	switch ($_GET["action"]) 
	{
	case "change":
		if (IsSet($_POST["enterUID"]))
		{
			if ($_POST["Type"] == "Secure")
			{
				$SQL2 = "UPDATE `UserCVS` SET ";
			  	$SQL_CVS = "SELECT * FROM `UserCVS` WHERE `UID`='". $_POST["enterUID"]. "'";
				$Erg_CVS =  mysql_query($SQL_CVS, $con);
				$CVS_Data = mysql_fetch_array($Erg_CVS);
				$CVS_Data_i = 1;
				foreach ($CVS_Data as $CVS_Data_Name => $CVS_Data_Value) 
				{
					if( ($CVS_Data_i+1)%2 && $CVS_Data_Name!="UID") {
						if( $CVS_Data_Name == "GroupID")
						{
							if( $_POST["enterUID"] > 0 )
								$SQL2.= "`$CVS_Data_Name` = '". $_POST["GroupID"]."', ";
							else
								$SQL2.= "`$CVS_Data_Name` = NULL, ";
						} else {
							$SQL2.= "`$CVS_Data_Name` = '". $_POST[$CVS_Data_i]."', ";
						}
					}
			    		$CVS_Data_i++;
				}
				$SQL2 = substr( $SQL2, 0, strlen($SQL2)-2 );
				$SQL2.= "  WHERE `UID`='". $_POST["enterUID"]. "' LIMIT 1;";
				echo "<br>Secure-";
				$Erg = db_query($SQL2, "change user CVS");
				if ($Erg == 1) {
					echo "&Auml;nderung wurde gesichert...\n";
				} else {
					echo "Fehler beim speichern...\n(". mysql_error($con). ")";
				}
			}
			else
				echo "<h1>Fehler: Unbekanter Type (". $_POST["Type"]. ") �bergeben\n</h1>\n";
		}
		else
			echo "<h1>Fehler: UserID (enterUID) wurde nicht per POST �bergeben</h1>\n";
		break;

	case "delete":
		if (IsSet($_POST["enterUID"]))
		{
			echo "delate User...";
			$SQL="DELETE FROM `User` WHERE `UID`='". $_POST["enterUID"]. "' LIMIT 1;";
			$Erg = db_query($SQL, "User delete");
			if ($Erg == 1) {
				echo "&Auml;nderung wurde gesichert...\n";
			} else {
				echo "Fehler beim speichern...\n(". mysql_error($con). ")";
			}
			
			echo "<br>\ndelate UserCVS...";
			$SQL2="DELETE FROM `UserCVS` WHERE `UID`='". $_POST["enterUID"]. "' LIMIT 1;";
			$Erg = db_query($SQL2, "User CVS delete");
			if ($Erg == 1) {
				echo "&Auml;nderung wurde gesichert...\n";
			} else {
				echo "Fehler beim speichern...\n(". mysql_error($con). ")";
			}
			
			echo "<br>\ndelate UserEntry...";
			$SQL3="UPDATE `ShiftEntry` SET `UID`='0', `Comment`=NULL ".
				  "WHERE `UID`='". $_POST["enterUID"]. "';";
			$Erg = db_query($SQL3, "delate UserEntry");
			if ($Erg == 1) {
				echo "&Auml;nderung wurde gesichert...\n";
			} else {
				echo "Fehler beim speichern...\n(". mysql_error($con). ")";
			}
		}
		break;
	} // end switch

// ende - Action ist gesetzt 
} elseif ( IsSet($_GET["new"]) &&  ($_SESSION['CVS']["admin/group.php"]=="Y") ) {
	echo "Gesendeter Befehl: ". $_GET["new"]. "<br>";
	
	switch ($_GET["new"]) 
	{
	case "newGroup":
		echo "\tGenerate new Group ID...\n";
		$SQLid="SELECT MIN(`UID`) FROM `UserCVS`;";
		$Erg = mysql_query( $SQLid);
		
		if( mysql_num_rows($Erg) == 1) {
			$NewId = mysql_result( $Erg, 0, 0)-1;
			$SQLnew1 = "INSERT INTO `UserGroups` (`UID`, `Name`) VALUES ('$NewId', '". $_POST["GroupName"]. "' );";
			$SQLnew2 = "INSERT INTO `UserCVS` (`UID`, `GroupID`) VALUES ('$NewId', NULL );";
			echo "\t<br>Generate new UserGroup ...\n";
			$ErgNew1 = db_query($SQLnew1, "create UserGroups Entry");
			if ($ErgNew1 == 1) 
			{
				echo "\t<br>Generate new User rights...\n";
				$ErgNew2 = db_query($SQLnew2, "UserCVS Entry");
				if ($ErgNew1 == 1) {
					echo "\t<br>New group was created.\n";
				} else {
					echo "Error on creation\n(". mysql_error($con). ")";
				}
			} else {
				echo "Error on creation\n(". mysql_error($con). ")";
			}

		}

		
		break;
	}
} else {
	// kein Action gesetzt -> abbruch
	echo "Unzul&auml;ssiger Aufruf.<br>Bitte neu editieren...";
}

include ("../../includes/footer.php");
?>