Page 1 of 1

PHPWCMS is changing code

Posted: Thu 4. Apr 2013, 22:31
by B1234
Hello!

I was wondering if you guys could help me.

I use PHP scandir to read out a dir and echo a few links, nothing too fancy.
On my own server, without PHPWCMS, it works fine. But with PHPWCMS is does partially.

The filenames are echo'ed great without PHPWCMS but it seems that somewhere in the code it is changing the dates in the filenames.
For example it should echo this:

12_ December 2010 - webversie.pdf

But instead it echo's this:
12_" december 2010 - webversie.pdf

And by doing that it makes the <a href tag confused. Changing the code to ' and other things didnt work.

My question is how can I make sure that PHPWCMS doesn't change my code. Outside PHPWCMS, running the PHP directly, worked on 2 different servers.

Thank you!

Regards,
Bas

Re: PHPWCMS is changing code

Posted: Sun 7. Apr 2013, 12:06
by Oliver Georgi
maybe you misunderstood how to use. Hard to tace your problem without knowhing what content part, what kind of code. Use a frontend render script and replace a replacement tag… Inline PHP is not recommend and you should understand what happens. You cannot use it in HTML content part because text is html encoded then…

Re: PHPWCMS is changing code

Posted: Sun 7. Apr 2013, 12:27
by B1234
Thank you for the reply.

The code is not clean, but works outside PHPWCMS.

Code: Select all

<?php
//Tekst

echo "<font size=\"2\" face=\"Verdana\">
Het KK’tje is het clubblad dat de Kameleon Kinheim eens in de zoveel tijd uitgeeft. Een vaste verschijningsperiode is er niet, maar we proberen er om de paar maanden eentje uit te geven.
<br><br>
Op deze pagina vind je het archief met alle KK’tjes die tot nu toe zijn uitgegeven sinds het eerste exemplaar uit maart 2007. Telefoonnummers en e-mail adressen zijn geblindeerd, aangezien er over de jaren functies zijn verschoven en om de privacy van onze leden te waarborgen. Wanneer je een telefoonnummer of e-mailadres nodig hebt, raadpleeg dan de contactpagina van de website.
<br><br>
<strong>Archief:</strong><br> 
";


//KKtje Archief uitlezen


$bestanden = scandir("../archiefwebsite/");

$huidigjaar = "";

foreach ($bestanden as $name) {
	$naam = explode(".pdf", $name);
	
	//echo var_dump($name);
	
	if(!$naam || !$name || $naam=="." || $name=="." || $naam==".." || $name==".."){}else{
		
	$bestandsnaam = $naam[0];
	
	$tekstweg = str_replace(" - webversie", "", $bestandsnaam);
	$dingweg = str_replace("_", " ", $tekstweg);
	
	$bn = explode(" ", $dingweg);
	
	$nummer = $bn[0];
	$weergeven_naam = $bn[2]." ".$bn[3];
	
	$jaar = $bn[2];
	
	//echo " ".$name." <br>";
		
    echo "<br /><a href='http://www.kameleonkinheim.nl/wcms/archiefwebsite/".$bestandsnaam.".pdf' target='_blank'>".$weergeven_naam."</a>";
	}
}

echo "
</font>";

?>
Content type is external content (Externe content in Dutch)
Custom path or url is http://www.kameleonkinheim.nl/wcms/kktj ... tlezen.php
By opening that like directly you'll see that it works. Within phpwcms it does not. the page within phpwcms is hidden at the moment..

Thank you for your help I hope it's a little bit more clear.

Re: PHPWCMS is changing code

Posted: Sun 7. Apr 2013, 12:40
by juergen
just remember, having PHP inside a php rendering engine is not as easy as copy & paste.

You have to pass this through the var which does all the rendered output ...

$conten['all'] ....

you will find examples in /frontend_render/ dir

not shure if {PHP:....} tag is still alive, which might do nearly the same for you

http://www.phpwcms-docu.de/system_tags.phtml

Re: PHPWCMS is changing code

Posted: Sun 7. Apr 2013, 14:59
by axelko
Hi,

Why not just upload the 5 pdf files in the phpwcms file center and use the content part 'lijst met bestanden uit bestandsbeheer' to place the pdf files on the right place/page? Easy solution with standard phpwcms functionality.

Kind regards,

Axel

Re: PHPWCMS is changing code

Posted: Sun 7. Apr 2013, 15:11
by B1234
Hey Axelko,

Because in reality it's 30+ pdf's. I would like to drop them in a folder via FTP and let the script echo them on the website. Less work for me.

Bas

Re: PHPWCMS is changing code

Posted: Sun 7. Apr 2013, 15:24
by Oliver Georgi
Do not include the script, choose second option: own path/file or URL and use the full qualified URL from your post here. Otherwise it include but not eval the PHP code.

But this function has several security related things built-in. Better use frontend render.