{{indexmenu_n>100}}
====== Multimedia: Kopieren einer SWF Datei in ein nicht geschütztes Verzeichnis ======
Wird der Multimedia-CP verwendet um eine intern geladene //(Dateizentrale)// Flash-SWF-Datei anzuzeigen, wird die Datei im Frontend nicht angezeigt.
Der Grund für dieses Verhalten ist der Schutz des Verzeichnisses "/filearchive/" durch eine .htaccess Datei.
**Es gibt zwei Lösungen für dieses Problem:**
**1.** Die .htaccess Datei deaktivieren \\
**2.** Script: Kopieren der gewünschten Datei in ein nicht geschütztes Verzeichnis und bereitstellen der Datei aus diesem Verzeichnis heraus \\
**Ich spreche hier die zweite Methode an.**
\\
===== Beschreibung: =====
**Script:**
Während des CP Aufrufs ermittelt das Script den relevanten Dateiname aus dem HTML-Quelltext und sucht diese Datei im nicht geschützten Verzeichnis. Wenn diese Datei dort nicht existiert, wird eine Kopie der Datei aus "/filearchive/" in "/content/tmp/" angelegt und der HTML Quelltext an den neuen Verzeichnisnamen angepasst.
**Wenn die Originaldatei in "/filearchive/" gelöscht wird, bleibt die Kopie in "/content/tmp/" erhalten !!**
\\
----
Docu: -- \\
Forum: [[http://forum.phpwcms.org/viewtopic.php?p=126267|Flash swf file doesn't display in multimedia content part]] \\
**Autor:** K.Heermann (flip-flop) [[http://planmatrix.de]] \\
**CMS Version:** >= 1.4x \\
**Version:** V1.0 //(07.09.2010)// \\
**Bedingung:** -> [[http://www.phpwcms-docu.de/confincphp_de.phtml|/config/phpwcms/conf.inc.php]] \\
* $phpwcms['allow_ext_init'] = 1;
----
\\
===== Beispieltemplate: =====
Für eine bessere Identifizierung und Laufzeitoptimierung muss ##%%%%## in das Template eingesetzt werden.
Datei: **template/inc_cntpart/multimedia/copy_swf.tmpl**
[MULTIMEDIA]
{MULTIMEDIA}
[/MULTIMEDIA]
\\
===== PHP: =====
Datei: **/template/inc_script/frontend_init/cp_trig_multimedia_copy_swf.php**
into your multimedia
* template for a better identification of this CP.
*
* folder: /template/inc_cntpart/multimedia/
*
*
[MULTIMEDIA]
{MULTIMEDIA}
[/MULTIMEDIA]
*
* *****************************************************************************
*/
function CP_MULTIMEDIA_COPY_SWF($text, & $data) {
// CP type multimedia = 9
if( $data['acontent_type'] == 9 AND strpos($text, '') ) {
// Is there any swf file in source?
if (preg_match('@value="'.PHPWCMS_FILES.'(.*?)\.swf"@i', $text, $filename)) {
// Yes it is and we have catched the filename
if ($filename[1] ) {
$source = PHPWCMS_FILES.$filename[1].'.swf'; // Source dir and filename
$target = 'content/tmp/'.$filename[1].'.swf'; // Destination dir and filename
$error = false;
// file already exists in destination dir?
if (!is_file ($target)) {
// No, please copy into
if (!copy($source, $target)) {
$error = true;
}
}
// Change folder in html source
$text = preg_replace('@="'.$source.'"@i','="'.$target.'"',$text);
}
}
if ($error)
str_replace('','Error while copying the file!!
',$text);
else
str_replace('','',$text);
}
return $text;
} // ---- END function
register_cp_trigger('CP_MULTIMEDIA_COPY_SWF');
?>