| 1 |
lars |
1 |
<?php
|
|
|
2 |
// Settings
|
|
|
3 |
require_once "../connect2.php";
|
|
|
4 |
|
|
|
5 |
// Web Verzeichnis, welches unkonvertierte Bilder enthält
|
|
|
6 |
$dir = '/web/apache/culina.de/images/directory/4/';
|
|
|
7 |
|
|
|
8 |
// Webrechte und Bildspezifische einstellungen, zu finden in den Websettings
|
|
|
9 |
$stdSettings = "Bild2:;300;400;kl;120;120;mini;40;40";
|
|
|
10 |
|
|
|
11 |
// Image Typen die konvertiert werden können!
|
|
|
12 |
$iTypes = "(.gif)|(.jpg)|(.png)";
|
|
|
13 |
|
|
|
14 |
$pMessage = "<strong>Preview Command for converting: %s</strong><hr><br>";
|
|
|
15 |
$cMessage = "<strong>Converting Image: %s</strong><hr><br>";
|
|
|
16 |
$useDB = "content_management";
|
|
|
17 |
|
|
|
18 |
if ($PHP_AUTH_USER=='admin')
|
|
|
19 |
{
|
|
|
20 |
if ($_POST['ID'])
|
|
|
21 |
{
|
|
|
22 |
$sql = "SELECT * FROM $useDB.webs WHERE ID = ".$_POST['ID'];
|
|
|
23 |
$webDefault = mysql_query ($sql) or mail("markus@weban.de","Fehler in imageConverter.php","Benutzer: ".$PHP_AUTH_USER."\n".mysql_errno().": ".mysql_error()."<hr>$sql<hr>","from: content-management");
|
|
|
24 |
$defaultSettings = mysql_fetch_assoc($webDefault);
|
|
|
25 |
|
|
|
26 |
$sql = "SELECT * FROM $useDB.webs_properties WHERE $useDB.webs_properties.webs= ".$_POST['ID'];
|
|
|
27 |
$result = mysql_query ($sql) or print(mysql_error()."<hr>".$sql);
|
|
|
28 |
while ($web_settings=mysql_fetch_assoc($result))
|
|
|
29 |
{
|
|
|
30 |
foreach(array_keys($web_settings) AS $elem)
|
|
|
31 |
{
|
|
|
32 |
$webResult[$web_settings['ID']] = $web_settings['Bezeichnung'];
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
?>
|
|
|
38 |
<form name="imageConvert" action="<?=$self;?>" method="POST">
|
|
|
39 |
<table border="1" cellspacing="0" cellpadding="2" align="center">
|
|
|
40 |
<tr>
|
|
|
41 |
<td colspan="2" class="links">Bild Konverter</td>
|
|
|
42 |
</tr>
|
|
|
43 |
<tr>
|
|
|
44 |
<td valign="top" class="links">Datenbank: </td>
|
|
|
45 |
<td class="rechts">
|
|
|
46 |
|
|
|
47 |
<select name="ID" size="5" OnChange="document.imageConvert.submit();">
|
|
|
48 |
<?php
|
|
|
49 |
$sql = "SELECT * FROM $useDB.webs ORDER by datenbank ASC";
|
|
|
50 |
$websResult = mysql_query ($sql) or mail("markus@weban.de","Fehler in imageConverter.php","Benutzer: ".$PHP_AUTH_USER."\n".mysql_errno().": ".mysql_error()."<hr>$sql<hr>","from: content-management");
|
|
|
51 |
|
|
|
52 |
while ($db=mysql_fetch_assoc($websResult))
|
|
|
53 |
{
|
|
|
54 |
if ( !empty($db['datenbank']) )
|
|
|
55 |
$buffer[] = $db;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
//$buffer = array_reverse($buffer);
|
|
|
59 |
|
|
|
60 |
foreach($buffer AS $db) {
|
|
|
61 |
?>
|
|
|
62 |
<option value="<?= $db['ID'] ?>" <?= ($db['ID']==$_POST['ID']) ? 'selected': '' ?>>
|
|
|
63 |
<?= $db['datenbank'] ?>
|
|
|
64 |
</option>
|
|
|
65 |
<?php
|
|
|
66 |
}
|
|
|
67 |
?>
|
|
|
68 |
</select>
|
|
|
69 |
</td>
|
|
|
70 |
</tr>
|
|
|
71 |
<tr>
|
|
|
72 |
<td class="links">Webpfad: </td>
|
|
|
73 |
<td class="rechts">
|
|
|
74 |
<input name="webpath" type="text" onFocus="this.select();" value="/web/apache/<?= str_replace("_",".",$defaultSettings ['datenbank']) ?>" size="40">
|
|
|
75 |
<br />
|
|
|
76 |
<label>
|
|
|
77 |
<select name="imagePath" id="imagePath">
|
|
|
78 |
<option value="images/Bild_1/" selected="selected"<?= ($_POST['imagePath']=='images/Bild_1/' || !$_POST['imagePath']) ? ' selected="selected"' : '' ?>>Bild 1</option>
|
|
|
79 |
<option value="images/Bild_2/"<?= ($_POST['imagePath']=='images/Bild_2/') ? ' selected="selected"' : '' ?>>Bild 2</option>
|
|
|
80 |
<option value="images/Bild_3/"<?= ($_POST['imagePath']=='images/Bild_3/') ? ' selected="selected"' : '' ?>>Bild 3</option>
|
|
|
81 |
<option value="images/directory/1/"<?= ($_POST['imagePath']=='images/directory/1/') ? ' selected="selected"' : '' ?>>Directory Bild 1</option>
|
|
|
82 |
<option value="images/directory/2/"<?= ($_POST['imagePath']=='images/directory/2/') ? ' selected="selected"' : '' ?>>Directory Bild 2</option>
|
|
|
83 |
<option value="images/directory/3/"<?= ($_POST['imagePath']=='images/directory/3/') ? ' selected="selected"' : '' ?>>Directory Bild 3</option>
|
|
|
84 |
<option value="images/directory/4/"<?= ($_POST['imagePath']=='images/directory/4/') ? ' selected="selected"' : '' ?>>Directory Bild 4</option>
|
|
|
85 |
</select>
|
|
|
86 |
</label>
|
|
|
87 |
</td>
|
|
|
88 |
</tr>
|
|
|
89 |
<tr>
|
|
|
90 |
<td valign="top" class="links">WebSettings: <br>
|
|
|
91 |
</td>
|
|
|
92 |
<td class="rechts" valign="top">
|
|
|
93 |
<?php
|
|
|
94 |
if (is_array($webResult)) {
|
|
|
95 |
foreach (array_keys($webResult) AS $setting) {
|
|
|
96 |
?>
|
|
|
97 |
<?= $setting ?> <input name="settingText" type="text" value="<?=$webResult[$setting];?>" size="40">
|
|
|
98 |
<input name="setting" type="radio" value="<?= $setting ?>" <?= ($_POST['setting']==$setting) ? 'checked': '' ?>/><br />
|
|
|
99 |
<?php
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
?>
|
|
|
103 |
</td>
|
|
|
104 |
</tr>
|
|
|
105 |
<tr>
|
|
|
106 |
<td valign="top" class="links">Preview:<br />
|
|
|
107 |
</td>
|
|
|
108 |
<td class="rechts" valign="top">
|
|
|
109 |
<input name="preview" type="checkbox" value="true"<?= ($_POST['preview']=='true' || !$_POST['preview']) ? ' checked': '' ?>/>
|
|
|
110 |
<br />
|
|
|
111 |
</td>
|
|
|
112 |
</tr>
|
|
|
113 |
<tr>
|
|
|
114 |
<td align="right" colspan="2" class="links">
|
|
|
115 |
<input type="submit" name="Abschicken" value="Abschicken" OnClick="document.imageConvert.submit();">
|
|
|
116 |
<input type="reset" name="Zurücksetzen" value="Zurücksetzen">
|
|
|
117 |
</td>
|
|
|
118 |
</tr>
|
|
|
119 |
</table>
|
|
|
120 |
</form>
|
|
|
121 |
<?php
|
|
|
122 |
$_POST['preview']= $_POST['preview']=='true' ? true : false;
|
|
|
123 |
|
|
|
124 |
if($_POST['setting'] && $_POST['webpath']) {
|
|
|
125 |
$dir = $_POST['webpath']."/".$_POST['imagePath'];
|
|
|
126 |
$Pfad = $dir;
|
|
|
127 |
$d = dir($dir);
|
|
|
128 |
while (false !== ($files = $d->read())) {
|
|
|
129 |
if (eregi($iTypes, $files)) {
|
|
|
130 |
$image = $dir.$files;
|
|
|
131 |
$image_name = $files;
|
|
|
132 |
|
|
|
133 |
printf(($_POST['preview']=='true') ? $pMessage : $cMessage,$image);
|
|
|
134 |
|
|
|
135 |
// $Imagenummer extrahieren
|
|
|
136 |
$Imagenummer=explode("_",$elem);
|
|
|
137 |
$Imagenummer=$Imagenummer[1];
|
|
|
138 |
$DatenID = "bild".$Imagenummer;
|
|
|
139 |
$web_rechte[modul_name][tool_name][$DatenID] = $webResult[$_POST['setting']];
|
|
|
140 |
$Imagedaten = array_chunk(explode(";", $web_rechte[modul_name][tool_name][$DatenID]),3);
|
|
|
141 |
$Imagedaten[0][0] = "";
|
|
|
142 |
/*
|
|
|
143 |
Imagedaten möglich Werte:
|
|
|
144 |
0: Titel des Feldes
|
|
|
145 |
1: max. Breite für Bild1 (original)
|
|
|
146 |
2: max. Höhe für Bild1 (original)
|
|
|
147 |
|
|
|
148 |
3: Pfad für Bild
|
|
|
149 |
4: max. Breite für Bild
|
|
|
150 |
5: max. Höhe für Bild
|
|
|
151 |
|
|
|
152 |
...
|
|
|
153 |
...
|
|
|
154 |
...
|
|
|
155 |
*/
|
|
|
156 |
// Höhe und Breite des Bildes bestimmen
|
|
|
157 |
$imgsize = GetImageSize ($image);
|
|
|
158 |
// $imgsize[0] $imgsize[1]
|
|
|
159 |
$executed = 0;
|
|
|
160 |
foreach($Imagedaten as $ImagedatenSet)
|
|
|
161 |
{
|
|
|
162 |
if ($ImagedatenSet[0] != "") {$ImagedatenSet[0].="/";}
|
|
|
163 |
// ---- Hier wird abgefragt ob das Bild verkleinert werden soll ---- //
|
|
|
164 |
if (count($ImagedatenSet) == 3)
|
|
|
165 |
{
|
|
|
166 |
//if (($imgsize[0] > $ImagedatenSet[1]) or ($imgsize[1] > $ImagedatenSet[2]))
|
|
|
167 |
//{
|
|
|
168 |
$procCommand="convert -scale ".$ImagedatenSet[1]."x".$ImagedatenSet[2]." ".$image." ".$Pfad.$ImagedatenSet[0].$image_name;
|
|
|
169 |
if ($_POST['preview']) {
|
|
|
170 |
echo $procCommand."<br>";
|
|
|
171 |
//
|
|
|
172 |
} else{
|
|
|
173 |
echo $procCommand."<br>";
|
|
|
174 |
$procHandle = popen ($procCommand, "r");
|
|
|
175 |
while ($return = fread($procHandle,4096)) {
|
|
|
176 |
echo nl2br($return);
|
|
|
177 |
}
|
|
|
178 |
$executed++;
|
|
|
179 |
/*
|
|
|
180 |
if($executed == 3)
|
|
|
181 |
exit();
|
|
|
182 |
*/
|
|
|
183 |
}
|
|
|
184 |
//}
|
|
|
185 |
//else
|
|
|
186 |
//{
|
|
|
187 |
//copy($image,$Pfad.$ImagedatenSet[0].$image_name);
|
|
|
188 |
//}
|
|
|
189 |
}
|
|
|
190 |
else
|
|
|
191 |
{
|
|
|
192 |
//copy($image,$Pfad.$ImagedatenSet[0].$image_name);
|
|
|
193 |
}
|
|
|
194 |
} // end foreach
|
|
|
195 |
echo "<br><hr>";
|
|
|
196 |
} // End If ereg
|
|
|
197 |
} // End While
|
|
|
198 |
$d->close();
|
|
|
199 |
}
|
|
|
200 |
}
|
|
|
201 |
?>
|