Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Retrict to certain file types/detect file types
Old 09-20-2007, 04:33 PM Retrict to certain file types/detect file types
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
hi im building a file management system for a CMS im making, and im not sure hwo to go about how to top this script from also opening images and that.

have a look here
http://dev.dansgalaxy.co.uk/cms/dev/...emo_jquery.php you can open them and view ocntents in the text area.. but how could i stop images and files like that which arnt text based from opening

Also if anyone knows, i want ot have it colour the code as well so like the syntax and stuff (must be xhtml valid)
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 09-20-2007, 05:40 PM Re: Retrict to certain file types/detect file types
coolkbk585's Avatar
Be good this Christmas!

Latest Blog Post:
KBlog has been deativated
Posts: 642
Name: Kyle
Location: Ada, MI
Trades: 0
Well, I'm not sure what you would have to do with that script to make it so only certain files can be opened. Is it your own code, or did you adapt it from something you found on the internet?

As for the source code highlighter, you might be able to adapt this into your site. It's just something that I found poking around the internet, so it might now be what you want, though.
__________________
<?php if($Adsense_Revenue > 0): define('HAPPINES','100%'); else: define('HAPPINESS', '0%') endif; ?>
coolkbk585 is offline
Reply With Quote
View Public Profile Visit coolkbk585's homepage!
 
Old 09-20-2007, 05:59 PM Re: Retrict to certain file types/detect file types
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
the file tree no its a script (which you can actually see if you look )

and the rest i made
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-20-2007, 06:08 PM Re: Retrict to certain file types/detect file types
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
just looked at the script, i might be able to simplfy it so ic an use it for my purpose thanks not sure how i could get it inside the textarea tho
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-21-2007, 02:02 AM Re: Retrict to certain file types/detect file types
Novice Talker

Posts: 9
Trades: 0
Hmm im a bit worried about the safty of this script, you should use post variable instead of url variable because a hacker could easily find how to use your url variable to edit any files on the server.

Quote:
but how could i stop images and files like that which arnt text based from opening
1st solution: Don't show your files that aren't text based in your tree. I suppose you use some kind of loop to show it so you just have to exclude files that do not have the right file extension. Personally i would still show them but i wouldn't make a link for them.

2nd solution: you prolly have a $path variable or something similar with the path of the file to show in the textarea, you can hide your textarea or redirect or whatever you want if its the wrong file type.

To code this there are tons of way, here is the lazy way ;D, prolly not the best.

Quote:

By the way, since
$path = 'myfile.html';



$findme1 = '.html';
$res1 = strpos($path , $findme1);
$findme2 = '.htm';
$res2 = strpos($path , $findme2);
$findme3 = '.php';
$res3 = strpos($path , $findme3);


//Then you continue for evry other type of file you want

if (($res1 === true) || ($res2 === true) || ($res3 === true)) {

//show your textarea



}
else{

// hide your textarea or redirect
}


By the way, id sudgest you to use a richtextbox instead of a textbox. you can do it yourself with the execCommand function and some simple javascript or you can find one free on the net.

Here is one:
http://www.htmlarea.com/

Last edited by Bakunin; 09-21-2007 at 02:18 AM..
Bakunin is offline
Reply With Quote
View Public Profile
 
Old 09-21-2007, 11:57 AM Re: Retrict to certain file types/detect file types
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Well the file tree is done, via a seperate script (which you can actually see in the files)

and i just use their functions like ([doc root]/cms/) or i could tell it to do what ever

im not too worried about security as once this is all in the CMS it wil have the security of that, and i want to get it functioning as i want then ill worry about it more

for this i am dont really want a wysiwyg for it, as the purpose of this is to manually edit the scripts.

I will however be using one for the content maker section when i develop it

and after alot of thought and writing my ideas and stuff for it down on paper (during this mornings maths lesson.. ) i decided i dont want to excldue files from the tree but want to handle how they displayed where my text area is,
so basically i want to be able to have two arrays one with img ext one with txt dox ext (php/html etc) and then if the file ext is a text doc it shows my code editor if it is a image it displays it, and it it is somethign else it shows a mesage.

i really want to have my code highlighted and i stumbled accross a php function highlight_file() which highlifghts it perfectly

only problem is when it is within the textarea it shows the tags used to colour it, and when i save it saves the tags too and also means the script becomes un useable. so i need a way to parse the highlighter tags and not the rest and also when saving to ignore the highlighter tags
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to Retrict to certain file types/detect file types
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.57381 seconds with 12 queries