|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
writting php tags into a file
hey again everyone,
I am trying to do some auto php code writting to a file that the user uploads. I can get the code in fine, but i can't see to get it between the <? ?> tags or even <?php ?> tags. What can i do so the code i write can be between those tags. If i can't get it to do that then when i turn the file into a .php file that code won't execute. Any help would be great. THANKS
__________________
Nothing is Everything
|
|
#2
|
|||
|
|||
|
i would say before you write anything to the file include the tags like this
PHP Code:
|
|
#3
|
|||
|
|||
|
still not working right. the right ?> tag comes in but the left one does not along with some php code in the center. There has to be a way to do this. Anyone else have any other ideas?
|
|
#4
|
|||
|
|||
|
let me see your code
|
|
#5
|
|||
|
|||
|
LOL, I deleted it cuz i was getting mad at it. Below is the gest of what i was trying to do.
$fp = fopen("file.php","w+"); fwrite("<? $objCart->addCart;?>",1024); fclose($fp); That is the very simple version i had way more but like i said i deleted it. Basically all i want to do is write some php code to a new .php file. The function with a dollar sign goes in ok along with the end tag but the first tag will not write. Actually i had now luck in writting it to the file at all. OK hope that helps. |
|
#6
|
||||
|
||||
|
unless i'm misinterpretting your question, its general discouraged to create PHP files on the fly like that...
what's stopping someone from putting malicious code in a file and running that? are you still trying to accomplish this, or have you given up and chosen a different method? |
|
#7
|
|||
|
|||
|
yup i am still trying to figure it out.
|
|
#8
|
|||
|
|||
|
PHP Code:
something like that should do the trick but i donno if u want to make the files as your going along or if you have the files already made..i tested this and it does work...=] hope this helps |
|
#9
|
|||
|
|||
|
i think the file would be created on the fly if necessary just give data.php a variable name that your site creates..then it will automatically create the page
|
|
#10
|
|||
|
|||
|
How are you trying to create the php file ?
If possible can you give us the whole script and it would be much better to use variables always use single quotes (') instead of double quotes (") example: fwrite ( $handler, '<?php' . 'echo $this->do; ' . '?>' ); |
|
#11
|
|||
|
|||
|
the w in the fopen automatically creates the file if does not exist. So all you have to do is create a variable that has what the file name will be. and for the line youve just gave me, it should be
PHP Code:
|
|
#12
|
||||
|
||||
|
I'm on board with MadCowDzz -- you have to be really careful about allowing people to write PHP to your site. What's to keep somebody from sending "unlink('/etc/passwd')" as their input and then loading the page you're writing?
|
|
#13
|
|||
|
|||
|
I guess unlink('/etc/passwd'); wont work with most of the hosts as nowadays most of the host take care of their security either by installing a good control panel or using chkroot() ...
But still, its better to be safe. ![]() |
|
#14
|
||||
|
||||
|
Heh, true, Mike_r, but you never know. With all the nickel and dime providers nowadays... How'sabout unlink($PHP_SELF) as an alternative?
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > writting php tags into a file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|