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
Prevent text copy using PHP?
Old 12-07-2009, 03:11 AM Prevent text copy using PHP?
frih's Avatar
Super Talker

Posts: 139
Name: abhi
Location: http://www.techbusy.org/
Trades: 0
Hello,

Is there any way to disable right click on webpages and selection of text using PHP?

I know it can be done using Javascript. But i am looking for PHP based method.
__________________

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
frih is offline
Reply With Quote
View Public Profile Visit frih's homepage!
 
 
Register now for full access!
Old 12-07-2009, 03:31 AM Re: Prevent text copy using PHP?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
You won't find any.

PHP runs at the page generation time. It's a server side language.
What happens in the browser is nothing PHP can influence. That's why all those techniques you saw were in javascript, as it runs browser side.
And beside, they are pretty useless, as any one hitting ctrl+u can view the source of the page anyway.

The only way you can prevent peoples getting your images and such, is to embed all of this into a flash control or a java applet.
As long as they are in an html page, people can fetch them.
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 12-07-2009 at 03:33 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-07-2009, 06:01 AM Re: Prevent text copy using PHP?
Knight13's Avatar
Defies a Status

Posts: 10,289
Name: Knight13
Location: Cleveland, Ohio
Trades: 0
If you are trying to disable right click for an image, people can just take a screen shot and get your image, and if people wants your text bad enough they will just sit their and copy it, so their is really no way of protecting your material if someone else wants it bad enough.
Knight13 is offline
Reply With Quote
View Public Profile
 
Old 12-07-2009, 06:18 AM Re: Prevent text copy using PHP?
Extreme Talker

Posts: 181
Name: David Jackson
Trades: 0
Rule of thumb

If you want to keep your content private and secure don't publish it online!
__________________

Please login or register to view this content. Registration is FREE

Last edited by davidj; 12-07-2009 at 07:07 AM..
davidj is offline
Reply With Quote
View Public Profile
 
Old 12-08-2009, 10:41 AM Re: Prevent text copy using PHP?
freezea's Avatar
Experienced Talker

Posts: 45
Trades: 0
This may work.
HTML Code:
<div unselectable="on">this text will NOT be selectable</div>
__________________

Please login or register to view this content. Registration is FREE
: Web-based Excel-like Java reporting tool.
freezea is offline
Reply With Quote
View Public Profile
 
Old 12-09-2009, 02:26 AM Re: Prevent text copy using PHP?
Knight13's Avatar
Defies a Status

Posts: 10,289
Name: Knight13
Location: Cleveland, Ohio
Trades: 0
That div code will not stop text from being selected.
Knight13 is offline
Reply With Quote
View Public Profile
 
Old 12-09-2009, 03:39 AM Re: Prevent text copy using PHP?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Knight13 View Post
That div code will not stop text from being selected.
Actually ...


... On Internet Exploder it would.

http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-09-2009, 06:20 AM Re: Prevent text copy using PHP?
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
But you could still select it in the source code, evan in IE I presume.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 12-09-2009, 07:58 AM Re: Prevent text copy using PHP?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Yes, it only makes the rendered element "non-selectable"
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-09-2009, 09:35 AM Re: Prevent text copy using PHP?
Knight13's Avatar
Defies a Status

Posts: 10,289
Name: Knight13
Location: Cleveland, Ohio
Trades: 0
I tried that code on IE 7 and i can highlight and copy the text.
Knight13 is offline
Reply With Quote
View Public Profile
 
Old 12-09-2009, 10:23 AM Re: Prevent text copy using PHP?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Convert it into VALID CODE and it does.
http://www.modtalk.co.uk/_site/code/.../unselectable/

<span>s are inline element and cannot contain block elements

<shocked>
Not like MS to demonstrate using invald HTML code </shocked>
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-09-2009, 01:35 PM Re: Prevent text copy using PHP?
frih's Avatar
Super Talker

Posts: 139
Name: abhi
Location: http://www.techbusy.org/
Trades: 0
Quote:
Originally Posted by freezea View Post
This may work.
HTML Code:
<div unselectable="on">this text will NOT be selectable</div>
Thanks , i was unaware about this.
__________________

Please login or register to view this content. Registration is FREE
|

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
frih is offline
Reply With Quote
View Public Profile Visit frih's homepage!
 
Old 12-09-2009, 02:12 PM Re: Prevent text copy using PHP?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by frih View Post
Thanks , i was unaware about this.
It may just be worthwhile reading the REST or the thread as well!!
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-09-2009, 02:54 PM Re: Prevent text copy using PHP?
Skilled Talker

Posts: 58
Trades: 0
If overall visitor experience means anything to you, I'd scrap the idea.

Your site copy is there to share with your visitors, no?

If it's really so tremendously compelling that you expect heaps of people to copy it, I'd probably take the "unselectable" bit in an entirely different direction and include a "print this page" option instead.

Site visitors are guests....be a good/generous host or stop inviting them

Last edited by whatsherface_21; 12-09-2009 at 02:58 PM.. Reason: overly creative spelling
whatsherface_21 is offline
Reply With Quote
View Public Profile
 
Old 12-10-2009, 01:52 AM Re: Prevent text copy using PHP?
Extreme Talker

Posts: 181
Name: David Jackson
Trades: 0
Does your 'Disable Select Text' function cover off Ctrl + A ?
__________________

Please login or register to view this content. Registration is FREE
davidj is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Prevent text copy using PHP?
 

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.87045 seconds with 12 queries