Import files with custom templates
Posted: Tue Mar 21, 2006 7:47 am
Hello,
I would like to implement an importation process in a website that can manage almost any kind of text file with a system of custom templates.
I would like your opinion about the methid I should use.
My first idea was to use the paterns with the function eval() of php.
For example
I have a text file like this
I would like to import in my database the list of couple (var,value)
So I wouls like the user can enter 3 string :
1st string, import template : for example
If we assume @myfunction is in fact a function that delete "\" in its parameter string, the result of my importation process in database will be :
I would like to use the php patterns as developping my own syntac will be a hard and long work. And I had plan to use eval() but is this the good method? Can't it be a security problem using eval()?
My last question is : Do you kow exemples of such a functionnality of which we can see the source code?
Thansk a ot for your help!
I would like to implement an importation process in a website that can manage almost any kind of text file with a system of custom templates.
I would like your opinion about the methid I should use.
My first idea was to use the paterns with the function eval() of php.
For example
I have a text file like this
Code: Select all
// Config file
toto_var="toto";
titi_var="\"titi\"";
// End of fileSo I wouls like the user can enter 3 string :
1st string, import template : for example
2nd string, var result :^(.+)="(.+)"$
2nd string, value result ://1
This is an example. The 1st, 2nd and 3rd strings can be changed by the visitor of my website through a form.@myfunction(//2)
If we assume @myfunction is in fact a function that delete "\" in its parameter string, the result of my importation process in database will be :
Code: Select all
variable | value
toto_var | toto
titi_var | "titi"My last question is : Do you kow exemples of such a functionnality of which we can see the source code?
Thansk a ot for your help!