Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?
2
	/* SETTINGS */
3
 
4
	// Benachrichten bei Fehler:
5
	$SETTINGS["ERROR_MSG_TO"] = "info@weban.de";
6
 
7
	// Verzeichnisse die abgeglichen werden sollen
8
	$SETTINGS["dirs"] = array
9
	(
10
		array
11
		(
12
			"Source"		=> "/web/apache/mediaran.de/images/Bild_7/kl",
13
			"Destination"	=> "/shopdata/artikel/standard"
14
		),
15
		array
16
		(
17
			"Source"		=> "/web/apache/mediaran.de/images/Bild_7",
18
			"Destination"	=> "/shopdata/artikel/detail"
19
		),
20
		array
21
		(
22
			"Source"		=> "/web/apache/mediaran.de/images/Bild_7/kl",
23
			"Destination"	=> "/bs_shopdata/artikel/standard"
24
		),
25
		array
26
		(
27
			"Source"		=> "/web/apache/mediaran.de/images/Bild_7",
28
			"Destination"	=> "/bs_shopdata/artikel/detail"
29
		)
30
	);
31
 
32
	// FTP SERVER LOGIN DATEN
33
	$SETTINGS["FTP_SERVER"] = array
34
	(
35
		"SERVER"	=> "s102378343.einsundeinsshop.de",
36
		"USER"		=> "u36425608",
37
		"PASSWORD"	=> "PWfRdNYW"
38
	);
39
 
40
	// Zeit in Sekunden : Sekunden*Minuten*Stunden
41
	$SETTINGS["TIMEOUT"] = 60 * 60 * 2;
42
 
43
	/* LOS GEHTS */
44
 
45
	// FTP VERBINDUNG AUFBAUEN
46
	$conn_id = ftp_connect($SETTINGS["FTP_SERVER"]["SERVER"]);
47
	$login_result = ftp_login
48
	(
49
		$conn_id,
50
		$SETTINGS["FTP_SERVER"]["USER"],
51
		$SETTINGS["FTP_SERVER"]["PASSWORD"]
52
	);
53
	ftp_pasv($conn_id,TRUE);
54
 
55
	if ((!$conn_id) || (!$login_result))
56
	{
57
        mail
58
		(
59
			$SETTINGS["ERROR_MSG_TO"],
60
			"Mediaran Bilderabgleich: Ftp-Verbindung konnte nicht hergestellt werden!",
61
			$SETTINGS["FTP_SERVER"]["SERVER"]."\n".
62
			$SETTINGS["FTP_SERVER"]["USER"]."\n".
63
			$SETTINGS["FTP_SERVER"]["PASSWORD"]
64
		);
65
        die;
66
    }
67
 
68
	$error_log=array();
69
	$success_log=array();
70
	foreach ($SETTINGS["dirs"] as $combo)
71
	{
72
		// Verzeichnis anwählen
73
		if (!ftp_chdir ($conn_id, $combo[Destination]))
74
		{
75
	        mail
76
			(
77
				$SETTINGS["ERROR_MSG_TO"],
78
				"Mediaran Bilderabgleich: Verzeichnis nicht gefunden !",
79
				$combo[Destination]
80
			);
81
			die;
82
		}
83
 
84
		$handle=opendir($combo["Source"]);
85
 
86
		while ($file = readdir ($handle))
87
		{
88
			if
89
			(
90
				($file != ".")
91
				&&
92
				($file != "..")
93
				&&
94
				(is_file ($combo["Source"]."/".$file))
95
				&&
96
				(time()-filemtime($combo["Source"]."/".$file) < $SETTINGS[TIMEOUT])
97
			)
98
			{
99
				if (ftp_put ($conn_id, $file, $combo["Source"]."/".$file, FTP_BINARY))
100
				{
101
					$success_log[]=$combo["Source"]."/".$file." -> ".$combo["Destination"]."/".$file."\n";
102
					//echo "[ OK ] ".$combo["Destination"]."/".$file."\n";
103
				}
104
				else
105
				{
106
					$error_log[] = $combo["Source"]."/".$file." -> ".$combo["Destination"]."/".$file."\n";
107
					//echo "[ KO ] ".$combo["Destination"]."/".$file."\n";
108
				}
109
			}
110
		}
111
		closedir($handle);
112
	}
113
	// FTP-Verbindung beenden
114
	ftp_close($conn_id);
115
	if (count($error_log) > 0)
116
	{
117
		mail ($SETTINGS["ERROR_MSG_TO"],"Mediaran Bilderabgleich: Upload-Fehler",implode("\n",$error_log));
118
	}
119
 
120
	if (count($success_log) > 0)
121
	{
122
		//mail ($SETTINGS["ERROR_MSG_TO"],"Mediaran Bilderabgleich: Upload-Status",implode("\n",$success_log));
123
	}
124
?>