| 1 |
lars |
1 |
<?php
|
|
|
2 |
$file = ( isset($_FILES["umsatz_file"]) ) ? $_FILES["umsatz_file"] : "";
|
|
|
3 |
if ( !$file )
|
|
|
4 |
{
|
|
|
5 |
?>
|
|
|
6 |
<form name="upload" method="post" action="" enctype="multipart/form-data">
|
|
|
7 |
<table width="100%">
|
|
|
8 |
<tr>
|
|
|
9 |
<td valign="top">
|
|
|
10 |
<table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
|
|
|
11 |
<tr bgcolor="#<? echo $webs[bgcolor_links] ?>">
|
|
|
12 |
<td colspan="2" style="color:#<? echo $webs[font_color_links] ?>;font-weight:bold">Benutzer: Importieren</td>
|
|
|
13 |
</tr>
|
|
|
14 |
<tr>
|
|
|
15 |
<td>
|
|
|
16 |
Datei
|
|
|
17 |
</td>
|
|
|
18 |
<td>
|
|
|
19 |
<input type="file" name="umsatz_file" />
|
|
|
20 |
</td>
|
|
|
21 |
</tr>
|
|
|
22 |
<tr bgcolor="#<? echo $webs[bgcolor_links] ?>">
|
|
|
23 |
<td colspan="2" align="right">
|
|
|
24 |
<input type="submit" value="Datei einlesen" />
|
|
|
25 |
</td>
|
|
|
26 |
</tr>
|
|
|
27 |
</table>
|
|
|
28 |
</td>
|
|
|
29 |
<td width="77" align="right">
|
|
|
30 |
<table width="67" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#FFFFFF" bordercolordark="#999999">
|
|
|
31 |
<tr>
|
|
|
32 |
<td class="frame"><a href="<? echo $self ?>?action=edit" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','../images/navigation/bt_neu_f2.gif',1)"><a href="<? echo
|
|
|
33 |
$self ?>?action=edit" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','../images/navigation/bt_neu_f2.gif',1)"><img name="Image5" border="0" src="../images/navigation/bt_neu.gif" width="67" height="40"></a></a></td>
|
|
|
34 |
</tr>
|
|
|
35 |
<tr>
|
|
|
36 |
<td class="frame"><a href="<? echo $self ?>?action=select_edit" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','../images/navigation/bt_bearbeiten_f2.gif',1)"><img name="Image6" border="0" src="../images/navigation/bt_bearbeiten.gif" width="67" height="40"></a></td>
|
|
|
37 |
</tr>
|
|
|
38 |
<tr>
|
|
|
39 |
<td><a href="<? echo $self ?>?action=delete<? if ( ($action ==
|
|
|
40 |
"edit") && ($ID > 0) )
|
|
|
41 |
{ ?>&ID[]=<?= $ID ?>" onClick="return confirm('Diesen Eintrag wirklich löschen ?');"<? }
|
|
|
42 |
else
|
|
|
43 |
{ ?>"<? } ?> onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('delete','','../images/navigation/bt_delete_f2.gif',1)"><img name="delete" border="0" src="../images/navigation/bt_delete.gif" width="67" height="40" alt="Eintrag löschen"></a></td>
|
|
|
44 |
</tr>
|
|
|
45 |
<?
|
|
|
46 |
$Feld = "php";
|
|
|
47 |
if ( isset($user_rechte[modul_name][tool_name][$Feld]) )
|
|
|
48 |
{
|
|
|
49 |
?>
|
|
|
50 |
<tr>
|
|
|
51 |
<td><a href="<? echo $self ?>?action=free_php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('import','','../images/navigation/bt_import_f2.gif',1)"><img name="php" border="0" src="../images/navigation/bt_import.gif" width="67" height="40" alt="Daten importieren"></a></td>
|
|
|
52 |
</tr>
|
|
|
53 |
<?
|
|
|
54 |
}
|
|
|
55 |
$Feld = "import";
|
|
|
56 |
if ( isset($user_rechte[modul_name][tool_name][$Feld]) )
|
|
|
57 |
{
|
|
|
58 |
?>
|
|
|
59 |
<tr>
|
|
|
60 |
<td><a href="<? echo $self ?>?action=import" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('import','','../images/navigation/bt_import_f2.gif',1)"><img name="import" border="0" src="../images/navigation/bt_import.gif" width="67" height="40" alt="Daten importieren"></a></td>
|
|
|
61 |
</tr>
|
|
|
62 |
<?
|
|
|
63 |
}
|
|
|
64 |
$Feld = "export";
|
|
|
65 |
if ( isset($user_rechte[modul_name][tool_name][$Feld]) )
|
|
|
66 |
{
|
|
|
67 |
?>
|
|
|
68 |
<tr>
|
|
|
69 |
<td><a href="<? echo $self ?>?action=export" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('export','','../images/navigation/bt_export_f2.gif',1)"><img name="export" border="0" src="../images/navigation/bt_export.gif" width="67" height="40" alt="Daten exportieren"></a></td>
|
|
|
70 |
</tr>
|
|
|
71 |
<?
|
|
|
72 |
}
|
|
|
73 |
?>
|
|
|
74 |
</table>
|
|
|
75 |
</td>
|
|
|
76 |
</tr>
|
|
|
77 |
</table>
|
|
|
78 |
</form>
|
|
|
79 |
<?
|
|
|
80 |
exit;
|
|
|
81 |
}
|
|
|
82 |
$cont = file( $_FILES["umsatz_file"]["tmp_name"] );
|
|
|
83 |
|
|
|
84 |
$i = 0;
|
|
|
85 |
foreach ( $cont as $row )
|
|
|
86 |
{
|
|
|
87 |
if ( $i != 0 )
|
|
|
88 |
{
|
|
|
89 |
$row = explode( "\t", $row );
|
|
|
90 |
if(empty($row[4]))
|
|
|
91 |
{
|
|
|
92 |
continue;
|
|
|
93 |
}
|
|
|
94 |
for ( $i = 0; $i < count($row); $i++ )
|
|
|
95 |
{
|
|
|
96 |
$row[$i] = trim( $row[$i] );
|
|
|
97 |
}
|
|
|
98 |
//$row[4] = substr ( $row[4] , 0, strlen($row[4])-2 );
|
|
|
99 |
$row[4] = str_replace( '.', '', $row[4] );
|
|
|
100 |
$row[4] = str_replace( ',', '.', $row[4] );
|
|
|
101 |
$data[] = $row;
|
|
|
102 |
}
|
|
|
103 |
$i++;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
require "MDB2.php";
|
|
|
107 |
require "Text/Password.php";
|
|
|
108 |
require "Mail.php";
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
$dsn = "mysql://" . $webs["db_username"] . ":" . $webs["db_password"] . "@" .
|
|
|
112 |
$webs["db_server"] . "/" . $webs[datenbank];
|
|
|
113 |
$db = MDB2::connect( $dsn, array() );
|
|
|
114 |
|
|
|
115 |
if ( !PEAR::isError($db) )
|
|
|
116 |
{
|
|
|
117 |
$r2 = $db->query( "SET CHARACTER SET latin1" );
|
|
|
118 |
$db->setFetchMode( MDB2_FETCHMODE_ASSOC );
|
|
|
119 |
|
|
|
120 |
foreach ( $data as $row )
|
|
|
121 |
{
|
|
|
122 |
$sql = "SELECT * FROM Logins WHERE Name2=$row[2]";
|
|
|
123 |
$res = $db->query( $sql );
|
|
|
124 |
if ( !PEAR::isError($res) )
|
|
|
125 |
{
|
|
|
126 |
if ( $res->numRows() )
|
|
|
127 |
{
|
|
|
128 |
$set_sql = "umsatz=$row[4]";
|
|
|
129 |
if ( count($row) == 6 )
|
|
|
130 |
{
|
|
|
131 |
$set_sql .= ", E_Mail='$row[5]'";
|
|
|
132 |
}
|
|
|
133 |
$sql = "UPDATE Logins SET $set_sql WHERE Name2=$row[2]";
|
|
|
134 |
$res2 = $db->query( $sql );
|
|
|
135 |
|
|
|
136 |
if ( PEAR::isError($res2) )
|
|
|
137 |
{
|
|
|
138 |
die( $res2->getUserinfo() . "<br>" );
|
|
|
139 |
}
|
|
|
140 |
}
|
|
|
141 |
else
|
|
|
142 |
{
|
|
|
143 |
if ( !empty($row[5]) )
|
|
|
144 |
{
|
|
|
145 |
$pw = Text_Password::create( 6 );
|
|
|
146 |
$set_sql = "$row[2], '$row[3]', '$row[4]', '$row[5]', '" . md5( $pw ) . "'";
|
|
|
147 |
$sql2 = "INSERT INTO Logins (Name2, Name1, umsatz, E_Mail, passwd) VALUES($set_sql)";
|
|
|
148 |
|
|
|
149 |
$body = "Sehr geehrte Kundin, sehr geehrter Kunde," . "\num Ihre Umsätze einsehen zu können, müssen Sie " .
|
|
|
150 |
"sich mit folgenden Daten auf unserer Webseite einloggen:" . "\nBenutzername: $row[5]\nPasswort: $pw\n\nSelbstverständlich " .
|
|
|
151 |
"können Sie Ihr Passwort jederzeit ändern.\n\nMit freundlichen " . "Grüßen\nIhr Topgetränke Ümminger Team\n";
|
|
|
152 |
|
|
|
153 |
$subject = "Zugangsdaten für die Einsicht der Umsätze";
|
|
|
154 |
|
|
|
155 |
$headers["Subject"] = $subject;
|
|
|
156 |
$headers["from"] = "info@topgetraenke-uemminger.de";
|
|
|
157 |
$mail = Mail::factory( "mail" );
|
|
|
158 |
|
|
|
159 |
// Prüfen, ob kein Fehler aufgetreten ist
|
|
|
160 |
if ( !PEAR::isError($mail) )
|
|
|
161 |
{
|
|
|
162 |
//Mail verschicken
|
|
|
163 |
$res3 = $mail->send( $row[5], $headers, $body );
|
|
|
164 |
if ( PEAR::isError($res3) )
|
|
|
165 |
{
|
|
|
166 |
echo "Konnte E-Mail nicht an $row[5] schicken." .
|
|
|
167 |
"Bitte schicken Sie diese manuell an den " . "Kunden!<br>Betreff: $subject<br>Nachricht:$body<br><br>";
|
|
|
168 |
}
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
}
|
|
|
172 |
else
|
|
|
173 |
{
|
|
|
174 |
$set_sql = "$row[2], '$row[3]', '$row[4]'";
|
|
|
175 |
$sql2 = "INSERT INTO Logins (Name2, Name1, umsatz) VALUES($set_sql)";
|
|
|
176 |
}
|
|
|
177 |
$res2 = $db->query( $sql2 );
|
|
|
178 |
if ( PEAR::isError($res2) )
|
|
|
179 |
{
|
|
|
180 |
die( $res2->getUserinfo() . "<br>" );
|
|
|
181 |
}
|
|
|
182 |
}
|
|
|
183 |
}
|
|
|
184 |
}
|
|
|
185 |
echo "Datei erfolgreich eingelesen!";
|
|
|
186 |
}
|
|
|
187 |
else
|
|
|
188 |
{
|
|
|
189 |
echo $db->getUserinfo();
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
?>
|