| Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
| Autor |
Nachricht |
jobradio Mitglied

|
Images in Ordner lesen und in Anzeige kompletieren |
|
|
Hallo,
das folgende Script habe ich bei http://www.homepage-total.de gefunden,
selber habe ich ein paar modifikationen eingebaut, es funktioniert auch, das einzige was nicht richtig ist, ist bei der Anzeige, es werden alle Grafiken 3 fach angezeigt.
Das Script soll verhindern das ich jede Woche die Seite erneut erstellen muss und das ganze so automatisiert wird.
| PHP-Code: | 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
| <?php
defined('mxMainFileLoaded') or die('access denied');
global $PHP_SELF, $pagetitle;
$pagetitle = "JRG Stream Statistic";
$pfad ="";
$pfad ="www.jobradio-germany.org/home/modules/stream_stats/images";
// rechte Bloecke an oder aus
$index = 0;
include_once("header.php");
OpenTable();
echo "<br /><center><a href=\"http://www.jobradio-germany.org/home/modules/stream_stats/create_png.php\" target=\"_blank\">Statistic Aktualisieren</a></center><br />";
// Verzeichnisname angeben
$verzeichnis = openDir("modules/stream_stats/images");
// Verzeichnis lesen
while ($file = readDir($verzeichnis)) {
// Höhere Verzeichnisse nicht anzeigen!
if ($file != "." && $file != ".." && $file != "empty.png") {
//erweiterungen entfernen
$vokale = array("_bg.png", "_ml.png", "_mlc.png");
$onlyconsonants = str_replace($vokale, "", "$file");
// Link erstellen
$ausgabe = "<table width=\"650\" height=\"280\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-image: url(http://".$pfad."/".$onlyconsonants."_bg.png); background-repeat:no-repeat\">
<tr style=\"background-image:url(http://".$pfad."/".$onlyconsonants."_ml.png); background-repeat:no-repeat\">
<td><img src=\"http://".$pfad."/".$onlyconsonants."_mlc.png\" width=\"650\" height=\"280\"></td>
</tr>
</table><br />";
}
print "<pre>";
print_r($ausgabe);
print "</pre>";
}
// Verzeichnis schließen
closeDir($verzeichnis);
CloseTable();
include_once("footer.php");
?> |
Info. drei Bilder ergeben eine komplette Grafik.
Nun hoffe ich das hier jemand helfen kann das, die komplette Grafik nur einmal angezeigt wird, statt 3x.
Wer sich ein bild über die Anzeige machen möchte kann dies hier tun.
Allternative bin ich auch über einen besseren lösungsweg dankbar.
LG Jobradio |
|
|
|
| 11 Dez 2009 20:14 |
|
  |
Werner Homepage-Total.de Moderator

|
 |
|
|
Ein mögliche Lösung (ungetestet!)
| PHP-Code: | 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
| <?php
defined('mxMainFileLoaded') or die('access denied');
global $PHP_SELF, $pagetitle;
$pagetitle = "JRG Stream Statistic";
$pfad ="";
$pfad ="www.jobradio-germany.org/home/modules/stream_stats/images";
// rechte Bloecke an oder aus
$index = 0;
include_once("header.php");
OpenTable();
echo "<br /><center><a href=\"http://www.jobradio-germany.org/home/modules/stream_stats/create_png.php\" target=\"_blank\">Statistic Aktualisieren</a></center><br />";
// Verzeichnisname angeben
$verzeichnis = openDir("modules/stream_stats/images");
$ausgabe = array();
// Verzeichnis lesen
while ($file = readDir($verzeichnis)) {
// Höhere Verzeichnisse nicht anzeigen!
if ($file != "." && $file != ".." && $file != "empty.png") {
//erweiterungen entfernen
$vokale = array("_bg.png", "_ml.png", "_mlc.png");
$onlyconsonants = str_replace($vokale, "", "$file");
// Link erstellen
$text = "<table width=\"650\" height=\"280\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-image: url(http://".$pfad."/".$onlyconsonants."_bg.png); background-repeat:no-repeat\">
<tr style=\"background-image:url(http://".$pfad."/".$onlyconsonants."_ml.png); background-repeat:no-repeat\">
<td><img src=\"http://".$pfad."/".$onlyconsonants."_mlc.png\" width=\"650\" height=\"280\"></td>
</tr>
</table><br />";
array_push($ausgabe, $text);
}
}
print "<pre>";
$ausgabe = array_unique($ausgabe);
print_r($ausgabe);
print "</pre>";
// Verzeichnis schließen
closeDir($verzeichnis);
CloseTable();
include_once("footer.php");
?> |
|
_________________ Bei Fragen oder Fehlermeldungen - Bitte ausführlichen Code posten!
Wie man Fragen richtig stellt |
|
|
| 12 Dez 2009 14:09 |
|
 |
jobradio Mitglied

|
 |
|
|
Mahlzeit,
die lösung ist schon wesendlich besser, allerdings bekomme ich auch den
array mit ausgegeben, s. Link oben.
| PHP-Code: | 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
| Array
(
[0] =>
[3] =>
[6] =>
[9] =>
[12] =>
[15] =>
[18] =>
[21] =>
) |
Es gibt aber noch einen Anderen Lösungsweg, doch da habe ich fehlermeldungen, die ich so selber nicht deuten kann, weil es einfach viel zu viele sind.
Folgende fehlermeldungen erscheinen da, denn das währe der einfachste weg der lösung, dann muss auch die generierung nicht mehr von hand angestoßen werden, (im Standalone kommen diese Meldungen nicht).
| Code: | Notice: Undefined variable: x_date in ../../includes/xml.class.php on line 56 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 64 Notice: Undefined variable: x_hour in ../../includes/xml.class.php on line 56 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 64 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 56 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 64 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: n_array in /modules/stream_stats/create_png2.php on line 103 Notice: Undefined variable: x_date in ../../includes/xml.class.php on line 56 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 64 Notice: Undefined variable: x_hour in ../../includes/xml.class.php on line 56 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 64 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 56 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 64 Notice: Undefined offset: -1 in /modules/stream_stats/create_png2.php on line 133 Notice: Undefined offset: 6 in /modules/stream_stats/create_png2.php on line 131 Notice: Undefined offset: 6 in /modules/stream_stats/create_png2.php on line 133 Notice: Undefined variable: x_date in ../../includes/xml.class.php on line 56 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 64 Notice: Undefined variable: x_hour in ../../includes/xml.class.php on line 56 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 64 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 56 Notice: Undefined variable: x_minute in ../../includes/xml.class.php on line 64 Notice: Undefined offset: 6 in /modules/stream_stats/create_png2.php on line 163 Notice: Undefined offset: 6 in /modules/stream_stats/create_png2.php on line 165
|
und das ist die xml.class.php dazu
| PHP-Code: | 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
| <?php
class xml{
function init(){ // Initialisierung und erzeugung des Arrays mit den Werten
$xml_file = file("" . MX_BASE_URL . "/modules/stream_stats/xml/" . $this->filename) or die("Dateifehler: " . $this->filename);
$xml_string = implode($xml_file);
$xml_string = ereg_replace("^.*<radio", "<radio", $xml_string);
$x_parser = xml_parser_create();
xml_parse_into_struct($x_parser, $xml_string, $this->x_vals, $x_index);
xml_parser_free($x_parser);
}
function stats(){
foreach($this->x_vals as $x_val){
if($x_val['tag'] == "DATE" && $x_val['type'] == "open"){
$x_date = $x_val['attributes']['DAY'];
$this->date = $x_date;
}
if($x_val['tag'] == "HOUR" && $x_val['type'] == "open"){
$x_hour = $x_val['attributes']['HOUR'];
}
if($x_val['tag'] == "LISTENERS" && $x_val['type'] == "complete"){
$x_minute = $x_val['attributes']['MINUTE'];
$x_listener = $x_val['value'];
}
if($x_date != "" && $x_hour != "" && $x_minute != ""){
if($x_minute != $x_minute_)
$this->listeners[$x_date][$x_hour][$x_minute] = $x_listener;
}
$x_minute_ = $x_minute;
}
// echo "<pre>";
// print_r($this->x_listeners);
// echo "</pre>";
//
// exit();
}
function filename($filename){
$this->filename = $filename;
}
}
|
die create_png.php
| PHP-Code: | 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
| <?php
$max_listeners = 50; // Am besten in 50er Schritten
$vertical_lines = 4; // Senkrechte Linien: 0 - keine Linien, ansonsten alle x Stunden (x entspricht dem angegebenen Wert)
$text_color = "FFFFFF"; // Farbe des Textes auf dem Hintergrund
$line_color = "808000"; // Farbe der Linien auf dem Hintergrund
$ml_color = "FFFF00"; // Farbe der maximalen Zuhörer
$mls_color = "FFFF00"; // Farbe der maximalen Zuhörer
$cl_color = "800080"; // Farbe der durchschnittlichen Zuhörer
$directory = "modules/stream_stats/xml"; // Verzeichnis mit dem .xml Dateien
include("includes/xml.class.php");
$xml = new xml;
generate_all();
//generate_png("2005-01-18.xml");
//generate_background("2005-01-18");
function generate_all(){
global $directory;
$filenames = dir($directory);
while (false !== ($filename = $filenames->read())) {
if($filename != "." && $filename != ".." && $filename != "clients.xml"){
$filename = basename($filename, ".xml");
echo $filename . "<br />\n";
generate_background($filename);
generate_ml($filename);
generate_mlc($filename);
echo "<table style=\"background-repeat:no-repeat; background-image:url(" . MX_BASE_URL . "/modules/stream_stats/images/" . $filename . "_bg.png)\"><tr>";
echo "<td style=\"background-repeat:no-repeat; background-image:url(" . MX_BASE_URL . "/modules/stream_stats/images/" . $filename . "_ml.png)\" />";
echo "<img src=\"" . MX_BASE_URL . "/modules/stream_stats/images/" . $filename . "_mlc.png\" /></td></tr></table>";
// exit();
}
}
$filenames->close();
}
function generate_background($filename){
global $xml, $text_color, $line_color, $max_listeners, $vertical_lines;
$xml->filename($filename . ".xml");
$xml->init();
$xml->stats();
$pixel = 200 / $max_listeners;
$im = ImageCreateFromPNG ("" . MX_BASE_URL . "/modules/stream_stats/images/empty.png");
$date_part = explode("-", $xml->date);
$date = $date_part[2] . "." . $date_part[1] . "." . $date_part[0]; // deutsches Datum
$line_col = fromhex($im, $line_color);
$text_col = fromhex($im, $text_color);
ImageString($im, 5, 180, 15, "Tagesübersicht für " . $date, $text_col);
// horizontale Linien
ImageLine($im, 50, 45, 634, 45, $line_col);
ImageLine($im, 50, 95, 634, 95, $line_col);
ImageLine($im, 50, 145, 634, 145, $line_col);
ImageLine($im, 50, 195, 634, 195, $line_col);
ImageLine($im, 50, 245, 634, 245, $line_col);
// seitliche Beschriftung
$left_margin = 38 - (5 * strlen($max_listeners));
ImageString($im, 2, $left_margin, 38, $max_listeners, $text_col);
if(($max_listeners / 4) * 3 == round(($max_listeners / 4) * 3)){
$left_margin = 38 - (5 * strlen(($max_listeners / 4) * 3));
ImageString($im, 2, $left_margin, 88, (($max_listeners / 4) * 3), $text_col);
}
if($max_listeners / 2 == round($max_listeners / 2)){
$left_margin = 38 - (5 * strlen($max_listeners / 2));
ImageString($im, 2, $left_margin, 138, ($max_listeners / 2), $text_col);
}
if($max_listeners / 4 == round($max_listeners / 4)){
$left_margin = 38 - (5 * strlen($max_listeners / 4));
ImageString($im, 2, $left_margin, 188, ($max_listeners / 4), $text_col);
}
ImageString($im, 2, 34, 238, "0", $text_col);
// untere Beschriftung, senkrechte Linien und Hörerzahlen
for($count = 0; $count <= 23; $count++){
$x_pos = ($count * 25) + 50;
$string = sprintf("%02d", $count);
ImageString($im, 2, $x_pos, 258, $string, $text_col); // untere Beschriftung
$x_pos = ($count * 25) + 54;
$y_pos = 244 - ($n_array[$count] * $pixel);
if(!($count % $vertical_lines) && $vertical_lines != 0) // senkrechte Linien
ImageLine($im, $x_pos + 1, 40, $x_pos + 1, 249, $line_col);
}
ImagePNG($im, "images/" . $filename . "_bg.png");
ImageDestroy($im);
}
function generate_ml($filename){
global $max_listeners, $max_listeners, $vertical_lines, $xml, $ml_color;
$xml->filename($filename . ".xml");
$xml->init();
$xml->stats();
$im = ImageCreate(650, 280);
$background_color = ImageColorAllocate($im, 255, 255, 255);
ImageColorTransparent($im, $background_color);
$pixel = 200 / $max_listeners;
$hours = get_listeners($xml->listeners);
$ml_col = fromhex($im, $ml_color);
$n_array = $hours[0];
// Hörerzahlen
for($count = 0; $count <= 23; $count++){
$x_pos = ($count * 25) + 54;
$y_pos = 244 - ($n_array[$count] * $pixel);
$x_pos_2 = (($count - 1) * 25) + 54;
$y_pos_2 = 244 - ($n_array[$count - 1] * $pixel);
if($count > 0) // Verbindungslinien zwischen den Punkten
ImageLine($im, $x_pos + 1, $y_pos + 1, $x_pos_2 + 1, $y_pos_2 + 1, $ml_col);
ImageFilledRectangle($im, $x_pos, $y_pos, $x_pos + 2, $y_pos + 2, $ml_col);
}
ImagePNG($im, "images/" . $filename . "_ml.png");
ImageDestroy($im);
}
function generate_mlc($filename){
global $max_listeners, $max_listeners, $vertical_lines, $xml, $mls_color;
$xml->filename($filename . ".xml");
$xml->init();
$xml->stats();
$im = ImageCreate(650, 280);
$background_color = ImageColorAllocate($im, 255, 255, 255);
ImageColorTransparent($im, $background_color);
$pixel = 200 / $max_listeners;
$hours = get_listeners($xml->listeners);
$mls_col = fromhex($im, $mls_color);
$n_array = $hours[0];
// Hörerzahlen
for($count = 0; $count <= 23; $count++){
$x_pos = ($count * 25) + 54;
$y_pos = 244 - ($n_array[$count] * $pixel);
if($n_array[$count] == "")
$n_array[$count] = 0;
if($n_array[$count] <= 9)
$x_offset = 1;
else
$x_offset = 5;
ImageString($im, 2, $x_pos - $x_offset, $y_pos - 15, $n_array[$count], $mls_col); // Beschriftung der Punkte
}
ImagePNG($im, "images/" . $filename . "_mlc.png");
ImageDestroy($im);
}
function generate_png($filename){
global $max_listeners, $max_listeners, $vertical_lines, $xml;
$xml->filename($filename);
$xml->init();
$xml->stats();
$pixel = 200 / $max_listeners;
$hours = get_listeners($xml->listeners);
$c_array = $hours[0];
$n_array = $hours[1];
$pic_name = substr($filename, 0, -4);
$im = ImageCreateFromPNG ("images/empty.png");
$background_color = ImageColorAllocate ($im, 230, 230, 230);
$text_color = ImageColorAllocate($im, 255, 255, 255);
// $text_color = ImageColorAllocate($im, 255, 255, 255);
$bar_color_c = ImageColorAllocate($im, 128, 0, 128);
$bar_color_n = ImageColorAllocate($im, 255, 255, 0);
$line_color = ImageColorAllocate($im, 128, 128, 0);
$date_part = explode("-", $xml->date);
$date = $date_part[2] . "." . $date_part[1] . "." . $date_part[0]; // deutsches Datum
ImageString($im, 5, 180, 15, "Tagesübersicht für " . $date, $text_color);
// horizontale Linien
ImageLine($im, 50, 45, 634, 45, $line_color);
ImageLine($im, 50, 95, 634, 95, $line_color);
ImageLine($im, 50, 145, 634, 145, $line_color);
ImageLine($im, 50, 195, 634, 195, $line_color);
ImageLine($im, 50, 245, 634, 245, $line_color);
// seitliche Beschriftung
$left_margin = 38 - (5 * strlen($max_listeners));
ImageString($im, 2, $left_margin, 38, $max_listeners, $text_color);
if(($max_listeners / 4) * 3 == round(($max_listeners / 4) * 3)){
$left_margin = 38 - (5 * strlen(($max_listeners / 4) * 3));
ImageString($im, 2, $left_margin, 88, (($max_listeners / 4) * 3), $text_color);
}
if($max_listeners / 2 == round($max_listeners / 2)){
$left_margin = 38 - (5 * strlen($max_listeners / 2));
ImageString($im, 2, $left_margin, 138, ($max_listeners / 2), $text_color);
}
if($max_listeners / 4 == round($max_listeners / 4)){
$left_margin = 38 - (5 * strlen($max_listeners / 4));
ImageString($im, 2, $left_margin, 188, ($max_listeners / 4), $text_color);
}
ImageString($im, 2, 34, 238, "0", $text_color);
// untere Beschriftung, senkrechte Linien und Hörerzahlen
for($count = 0; $count <= 23; $count++){
$x_pos = ($count * 25) + 50;
$string = sprintf("%02d", $count);
ImageString($im, 2, $x_pos, 258, $string, $text_color); // untere Beschriftung
$x_pos = ($count * 25) + 54;
$y_pos = 244 - ($n_array[$count] * $pixel);
$x_pos_2 = (($count - 1) * 25) + 54;
$y_pos_2 = 244 - ($n_array[$count - 1] * $pixel);
$x_pos_3 = ($count * 25) + 54;
$y_pos_3 = 245 - ($c_array[$count] * $pixel);
$x_pos_4 = (($count - 1) * 25) + 54;
$y_pos_4 = 245 - ($c_array[$count - 1] * $pixel);
if(!($count % $vertical_lines) && $vertical_lines != 0) // senkrechte Linien
ImageLine($im, $x_pos + 1, 40, $x_pos + 1, 249, $line_color);
if($count > 0){ // Verbindungslinien zwischen den Punkten
ImageLine($im, $x_pos_3 + 1, $y_pos_3 + 1, $x_pos_4 + 1, $y_pos_4 + 1, $bar_color_n);
ImageLine($im, $x_pos + 1, $y_pos + 1, $x_pos_2 + 1, $y_pos_2 + 1, $bar_color_c);
}
if($listeners[$count] <= 9)
$x_offset = 1;
else
$x_offset = 5;
ImageFilledRectangle($im, $x_pos, $y_pos_3, $x_pos + 2, $y_pos_3 + 2, $bar_color_n);
ImageFilledRectangle($im, $x_pos, $y_pos, $x_pos + 2, $y_pos + 2, $bar_color_c);
ImageString($im, 2, $x_pos - $x_offset, $y_pos - 15, $n_array[$count], $text_color); // Beschriftung der Punkte
// ImageString($im, 2, $x_pos_3 - $x_offset, $y_pos_3 - 15, $c_array[$count], $text_color); // Beschriftung der Punkte
}
ImagePNG($im, "images/" . $xml->date . ".png");
ImageDestroy($im);
}
function get_listeners($l_array){
global $cut_through, $xml;
$cut_through_ = 0;
$cut_count = 0;
$filename = substr($xml->filename, 0, -4);
while($l_key = key($l_array[$filename])){
$max_worth = 0;
while($m_key = key($l_array[$filename][$l_key])){
$minute = $l_array[$filename][$l_key][$m_key];
if($minute > $max_worth)
$max_worth = $minute;
$cut_through_ += $minute;
$cut_count++;
next($l_array[$filename][$l_key]);
}
$c_array[abs($l_key)] = round($cut_through_ / $cut_count);
$n_array[abs($l_key)] = $max_worth;
next($l_array[$filename]);
}
return array($c_array, $n_array);
}
function fromhex($im, $string){
sscanf($string, "%2x%2x%2x", $red, $green, $blue);
return ImageColorAllocate($im, $red, $green, $blue);
}
|
Hoffe nun auf einen evtl, Lösungsvorschlag wie man das Array in der ausgabe ausblenden kann.
oder für den anderen Lösungsvorschlag, denn bei dem muss ich die datei create_png.php immer noch seperat aufrufen damit alle Grafiken generiert werden, sonst wird die grafik unvollständig angezeigt.
LG Kalle |
|
|
|
| 12 Dez 2009 16:06 |
|
 |
Werner Homepage-Total.de Moderator

|
 |
|
|
| jobradio hat Folgendes geschrieben: | Mahlzeit,
die lösung ist schon wesendlich besser, allerdings bekomme ich auch den
array mit ausgegeben, |
Was erwartest du den bei print_r, dieser zeigt das Array natürlich in dieser Form an.
Ersetze:
| PHP-Code: | 1 2 3 4 5 6
| <?php
print "<pre>";
$ausgabe = array_unique($ausgabe);
print_r($ausgabe);
print "</pre>";
?> |
durch folgendes
| PHP-Code: | 1 2 3 4 5 6
| <?php
$ausgabe = array_unique($ausgabe);
foreach ($ausgabe as $element) {
echo $element;
}
?> |
|
_________________ Bei Fragen oder Fehlermeldungen - Bitte ausführlichen Code posten!
Wie man Fragen richtig stellt |
|
|
| 13 Dez 2009 14:57 |
|
 |
jobradio Mitglied

|
 |
|
|
| Zitat: |
[/php]
durch folgendes
| PHP-Code: | 1 2 3 4 5 6
| <?php
$ausgabe = array_unique($ausgabe);
foreach ($ausgabe as $element) {
echo $element;
}
?> |
|
Oh man, da hätte ich selber drauf kommen müssen, habe mit sowas schon gearbeitet, aber manchmal sieht man vor lauter Bäumen den wald nicht.
Danke Werner
Jetzt habe ich nur noch ein problem mit meiner clients.php, die soll die clients.xml auslesen und entsprechend Player (Client) und die hits ausgeben, alles was ich bisher versucht habe war entweder eine weise seite (Keine ausgabe) oder ich habe den fehler nicht gefunden, allerdings kann es auch sein das ich in der Convertirung des xml erhebliche fehler hatte, da dies das erste mal der versuch war XML in php ordentlich aus zu geben.
hier mal den code der XML datei (auszugsweise nur sonst zu lang)
| PHP-Code: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <?xml version="1.0"?>
<radio>
<clients>
<client name="Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3/MPEG">1</client>
<client name="N/A">40</client>
<client name="Java/1.5.0_12">3</client>
<client name="Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.15) Gecko/2009101601 Firefox/3.0.15 GTB6 (.NET CLR 3.5.30729)/MPEG">1</client>
<client name="WinampMPEG/5.54">4</client>
<client name="WinampMPEG/5.09">5</client>
<client name="WinampMPEG/2.8">15</client>
<client name="WinampMPEG/5.35">2</client>
<client name="ultravox metadata puller">84</client>
<client name="GStreamer souphttpsrc libsoup/2.28.1">1</client>
<client name="NSPlayer/12.00.7100.0000 WMFSDK/12.00.7100.0000">1</client>
<client name="WinampMPEG/5.11">2</client>
<client name="Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)/MPEG">23</client>
</clients>
</radio> |
name = Player und die zahlen zwischen <client name =""> und </client>
sollen zusammen eine Tabelle ergeben, in der man die player (Clients) mit der vorkommenden Anzahl ausgeben, damit wir statistisch eine auswertung machen können, aber wie gesagt xml mit php auszugeben, habe ich bis gestern noch nie bewältigt und währe über einen lösungsansatz dankbar, gerade weil ich und den bekannten adressen, und mit Google sowie mit
PHP und XML einfach einfach keinen passenden lösungsansatz gefunden habe.
So hoffe das hier eine gewisser Ansatz bzw. Beispiel gegeben wird, möchte so nichts fertiges haben, aber einmal ist immer das erste mal.
aber vieleicht kann man ja auf grundlage der oben genannten xml.class.php einen Lösungsweg finden.
LG Kalle
Edit: Eingaben und Text vergessen |
|
|
|
| 13 Dez 2009 16:00 |
|
 |
jobradio Mitglied

|
Ausgabe des Codes aufteilen |
|
|
Das Script habe ich nun in einem Geschützten Verzeichnis für MP3 dateien eingebaut.
hier werden mehrere Dateierweiterungen ausgegeben
PDF, TXT, JPG und MP3.
Da die Seite aber viel zu lang wird, möchte ich das ganze nun Aufteilen auf mehrere Seiten.
Unter Homepage Total habe ich ein Script gefunden das datensütze auf mehrere Seiten aufteilt.
Da das Script aber in einem Array alles ausgibt, möchte ich per if dateien ausschließen oder muss ich den gesamten Code komplett umschreiben.
Hier mal den Code wie ich es versucht habe.
| PHP-Code: | 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
| <?php
error_reporting (0);
$genre = "";
$genre = "Rock, Slow-Rock, Hard-Rock, Heavy Metal";
$pagetitle = "JRG & HRA Promocenter - ".$genre."";
echo "<head><title>".$pagetitle."</title>";
$pfad ="";
$pfad ="****/***/Genres/Rock";
$dir = "";
$dir = "Genres/Rock";
echo "<h3>".$genre."</h3>";
// Verzeichnisname angeben
$verzeichnis = openDir("Genres/Rock");
$ausgabe = array();
// Verzeichnis lesen
while ($file = readDir($verzeichnis)) {
// Höhere Verzeichnisse nicht anzeigen!
if ($file != "." && $file != ".." && $file != "noimages.jpg") {
//erweiterungen entfernen
$vokale = array(".mp3", ".pdf", ".jpg", ".txt");
$onlyconsonants = str_replace($vokale, "", "$file");
$info = file_get_contents("".$dir."/".$onlyconsonants.".txt");
// Link erstellen
$text = "<fieldset style='width:90%'><legend style='background-color:#000; color:#FFF'>".$onlyconsonants."</legend><table width='98%' border='0' align='center' cellpadding='2' cellspacing='2'><tr>
<td rowspan='2' align='center' valign='middle' style='width:100px; height:100px'><img src='http://".$pfad."/".$onlyconsonants.".jpg' width='100'></td><td><table width='98%' border='1' cellspacing='2' cellpadding='2' class='table'>
<tr>
<td bgcolor='#006600'>".$info."</td>
</tr>
</table></td></tr>
<tr><td><table width='150' border='1' cellspacing='2' cellpadding='2' class='table' align='left'>
<tr>
<td bgcolor='#000066'><a href='http://".$pfad."/".$onlyconsonants.".mp3' target='_blank'>Download</a></td>
</tr>
</table>
<table width='150' border='1' cellspacing='2' cellpadding='2' class='table' align='left'>
<tr>
<td bgcolor='#000066'><a href='http://".$pfad."/".$onlyconsonants.".pdf' target='_blank'>Beschreibung</a></td>
</tr>
</table></td>
</tr>
</table></fieldset><br />";
array_push($ausgabe, $text);
}
}
$ausgabe = array_unique($ausgabe);
foreach ($ausgabe as $element) {
//echo $element;
##########################
###########Auf mehrere seiten Aufteilen ##############
// Daten auf mehreren Seiten aufteilen
// Datei "zitate.txt" in ein Array ($daten) einlesen
// Trennzeichen ist der Zeilenumbruch (CR)
$daten = $ausgabe;
// Wieviel Datensätze sollen pro Seite angezeigt werden
$daten_pro_seite = 3;
// Überprüfen ob über $_GET["seitenzahl"] eine Seitenzahl gesendet wurde
$seitenzahl = ((isset($_GET["seitenzahl"])) ? $_GET["seitenzahl"] : 0);
$fortlaufende_nummer = 0; // $fortlaufende_nummer auf 0 setzen
// Die Schleife zeigt jeden X-ten ($daten_pro_seite) Datensatz mit einem Link an
for ($zaehler = 0; $zaehler < count($daten); $zaehler = $zaehler + $daten_pro_seite) {
$fortlaufende_nummer++; // $fortlaufende_nummer erhöhen
// Mit dem Link wird seitenzahl=$zaehler als $_GET["seitenzahl"] übergeben
echo "<a href=\"?op=Rock&seitenzahl=$zaehler\"" .
// Die aktuelle Seite hervorheben
(($zaehler == $seitenzahl) ? ' class="mark"' : "").
">" . $fortlaufende_nummer . "</a> \n";
}
// Die ausgewählten Datensätze in einer Schleife ausgeben
for ($zaehler = $seitenzahl; $zaehler < ($seitenzahl + $daten_pro_seite); $zaehler++) {
echo "<p>" . ($zaehler + 1) . ". " . $daten[$zaehler] . "</p>\n";
}
##########################
}
// Verzeichnis schließen
closeDir($verzeichnis);
?> |
das ganze habe ich schon mit $element versucht, aber dann wird keine Ausgabe angezeigt.
Vielen Dank schon mal für die erneute Hilfe.
LG Jobradio |
|
|
|
| 25 März 2010 11:14 |
|
 |
|