Hallo
Ich möchte in einem Modul eine http Seite includen, nur wie kann ich das machen? Die normalen PHP Includes Funktionen ergeben immer fehlermeldungen.......
Dank und Gruss
			
			
									
						Module: Include einer WWW Seite
- 
				schlaucher
- Beiträge: 444
- Registriert: Mi 14. Sep 2005, 10:38
- Wohnort: Karlsruhe
- Kontaktdaten:
Hi, 
wenn Du eine lokale HTML Datei einfügen willst, dann versuche es mal mit folgendem Modul. Ich habe es hier mal im Forum gefunden und es funktioniert.
Modul HTML-Datei einfügen
Beschreibung:
Input:
Output:
Gruß
schlaucher
			
			
									
						wenn Du eine lokale HTML Datei einfügen willst, dann versuche es mal mit folgendem Modul. Ich habe es hier mal im Forum gefunden und es funktioniert.
Modul HTML-Datei einfügen
Beschreibung:
Code: Alles auswählen
Modul zum Einbinden einer HTML-Datei
Autor: Murat Purc, murat@purc.de
Version: 0.9
Wichtig:
Unter "Administration -> Mandanten -> Mandanteneinstellungen" ist eine folgende Variable einzufügen:
Typ   Name           Wert
dir   html.snippet   templates/snippets/
Das Verzeichnis "templates/snipplets/" (kann auch anders lauten) muss im im Client-Verzeichnis existieren und sollte auch HTML-Dateien enthalten.Code: Alles auswählen
?><?php
// input HTML-Snippet
cInclude('classes', 'contenido/class.client.php');
class cModHtmlSnippet{
	function cModHtmlSnippet(){
		global $cfgClient, $client;
		$this->selSnippet = "CMS_VALUE[0]";
		$cApiClient     = new cApiClient($client);
		$subdir         = $cApiClient->getProperty('dir','html.snippet', '');
		$this->counter  = 0;
		$this->path     = $cfgClient[$client]['path']['frontend'].$subdir;
		$this->htmlpath = $cfgClient[$client]['htmlpath']['frontend'].$subdir;
		$this->arrFiles = $this->_readDir($this->path);
	}
	function generateIncOptions(){
		$ret = '<option value="">'.mi18n("--- Datei auswählen ---").'</option>'."\n";
		foreach ($this->arrFiles as $pos => $file) {
			$sel  = ($file == $this->selSnippet) ? ' selected="selected"' : '';
			$ret .= '<option value="'.$file.'"'.$sel.'>'.$file.'</option>'."\n";
		}
		return $ret;
	}
	function _readDir($dir){
		$hDir = opendir($dir);
		while ($sFile = readdir($hDir)) {
			$isEmpty = ($sFile == '.' || $sFile == '..') ? true : false;
			$bIsDir  = (is_dir($dir.$sFile) && !$isEmpty) ? true : false;
			if(!$bIsDir && !$isEmpty) {
				$arrFiles[] = $sFile;
			}
		}
		closedir($hDir);
		return $arrFiles;
	}
} // class cModHtmlSnippet
$oMHS = new cModHtmlSnippet();
?>
<table cellspacing="0" cellpadding="3" border="0">
<tr><td valign="top" class="text_medium"><b><u><?php echo mi18n("Einzubindende HTML-Datei auswählen:"); ?></u></b></td></tr>
<tr><td class="text_medium">
	<select name="CMS_VAR[0]" class="text_medium">
	<?php echo $oMHS->generateIncOptions(); ?>
	</select>
</td></tr>
</table>
<?php
unset($oMHS);Code: Alles auswählen
<?php
// output HTML-Snippet
class cModHtmlSnippet{
	function cModHtmlSnippet(){
		global $client;
		$cApiClient    = new cApiClient($client);
		$this->path    = $cApiClient->getProperty('dir','html.snippet', '');
		$this->incFile = "CMS_VALUE[0]";
	}
	function generateOutput(){
		if ($this->incFile == '') {
			return;
		}
		$arr = explode('.', $this->incFile);
		$ext = strtolower($arr[count($arr)-1]);
		switch ($ext) {
			case 'html':
				// selected file is a html file, include file and pray that the user done right
				cInclude('frontend', $this->path.$this->incFile); break;
			case 'htm':
				// selected file is a htm file, include file and pray that the user done right
				cInclude('frontend', $this->path.$this->incFile); break;
			default:
				break;
		}
	} // function generateOutput()
} // class cModHtmlSnippet
$oMHS = new cModHtmlSnippet();
$oMHS->generateOutput();
unset($oMHS);
?>schlaucher