Jump to content

DJCMBear

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

About DJCMBear

  • Birthday 05/21/1992

Profile Information

  • Gender
    Not Telling

DJCMBear's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes and it does work so thanks for your help and it took me a while to test the code because i only just got onto my server to do it and now i can finish my system off =)
  2. yes so the only thing thats read is the number 3 and the rest of the php coding isnt read by the function.
  3. Thanks mjdamato for your reply and from what you suggested it's the same thing as i was going to do but I just wanted to know if it could be done on the server so that i could hide the files with a .ht 403 code but ill do it the easy way for now. And thanks to teamatomic for your reply and its a good function however i need the function to execute the file without the php codes there.
  4. Hi i'm in need of a bit of help with a function and even though im good at php coding I don't know how to form this function. What I want to do: What I want to do is create a function that will use the file read function but not read the php codes inside that file. e.g. <?php print "hello"; ?> would just send out the word hello, php codes that get information from a database would do the same, it would print out the information being written by the php code. Example of the database php codes: <?php $sql = "SELECT * FROM TABLE"; $res = mysql_query($sql); if($mysql_num_rows($res)){ while($row = mysql_fetch_array($res)){ print $row["table_data"]; } } ?> Lets say $row["table_data"] equals the name "Bob", that php code will send out the name Bob plus other names that could be printed from that php code and leave the php coding out so it does not get printed after being put through the ReadFile function. The Files: header.inc footer.inc index.php The Function: <?php function ReadFile($file){ $fh = fopen($file, 'r'); $theData = fread($fh, filesize($file)); fclose($fh); return $theData; } ?> All the function above does is reads the file and that means the text between the <? & ?> tags also get read, what I want to know is how I could make a function that calls the page as it is ment to be shown. E.G. - If I wanted to get the current year and on the "footer.inc" page I write <?=date('Y');?> what fopen does is read that as it is but what I need it to do is to run the code as it would normaly do and for example it would print out "2010" and thats what fopen would read. So <?=date('Y');?> on the footer.inc file will print out 2010 after going through the ReadFile function.
  5. You would have to use '../' to come out of the folder you are in.
  6. You wouldn't happen to know what i would need to write in the htconf file to make the server think the folder is the root would you?
  7. Hi I was just wondering how i could do this. I have a subdomain called apps so the url would be "http://apps.mysite.com/"and everything after that goes to the index.php file so a uri like "/test-app/test.php" would go to "/index.php?app=test-app&path=%2Ftest.php" and my php code will search inside the app-files folder and look for the folder called "test-app" and look inside that for test.php. so index.php will go to this file "/app-files/test-app/test.php". i want to know if theres a .ht code that will make my server think that the folder "test-app" is the root of the site so requests like php require / include cant access any file outside that folder. If this is possible can someone please help me find away to do this, thank you =).
  8. If you havent got one already use a .ht ErrorDocument code like this. ErrorDocument 404 http://www.yoursite.com/ If the file wasnt found then the HTTP/404 will be called and with the .ht 404 error code your site will see you want all errors to be redirected to your home page.
  9. I was just wondering if i used .ht to make the server think the folder its in is the root of the site would PHP requests such as require and include still allow users to include pages outside the folder or because the server thinks the folder is the root then they will not include pages outside that folder?
  10. ill make a php script so when a user creates a new app then the folder gets created and then a .ht file is written into it with the root codes in it sounds ok, i just have to figure out how i can write the root code now lol thanks for the help =)
  11. Thanks for the replys they are helpfull however im not using my own server and my server wont do something for just one user so i cant go through the server, I was thinking about .htaccess cus i use them files alot but i dont know if/how i could write something in that to let the server think thats the root folder and from what i know you cant access anything outside the root without telling your server that which mine hasnt. If someone knows a php or .htaccess code/function how i can do this then please feel free to tell me, thank you.
  12. Hi im trying to create an application section to my site, but I dont want the application developer to be able to require a file outside their folder when they require or include a file in their folder. So if a user created an application and created a file and put require('../index.php'); in the root dir and lets say that went to the main sites home i would want an error to show saying you cant require a page outside their root dir and not show that page. The file system would be like the index.php page which holds the codes that will show the application, and a folder called app-files and in the app-files folder it would have a folder for each app so if there was an app called free-codes the the path to that app would be '/app-files/free-codes/[path-to-files-user-has-creaded]' etc. So basicly the users app folder inside the app-files folder would be their base dir and you can't access anything outside that. If anyone knows of anyway I could do this please reply, Thank You.
  13. I have done it already
  14. I have finaly done it and it works like a dream Thanks for everyone's help
  15. Thanks for the replys and I'll try doing the code you said cags. and play_ im using id number becuase its a student id number which everyone knows and dont use the personal database id number so it dont matter if other users know the id numbers as they type @123456.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.