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