November 28, 2014


Copy Protect your Websites or Blogs from Fraudulent Users


           Nowadays,it has become a need to make your blog(bloggers too) copy protected since same copies would be found some where in the internet after few hours.This happens mostly through feeds where many sites would directly publish all our content from our site’s feeds.
Prevent copying of Text from your blogger or any sites
                It is possible to prevent copying the content of our blog by just adding some piece of code which will prevent fraudulent users to select the text.Insert the code into commonly visible area for all content,better place is footer area.

Copy Protected by <a href="http://www.techtipsmaster.com">Computer tech tips</a><script type="text/javascript">
var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
</script>

Prevent copying of Pictures from your blogger or any sites

1.Look through the source code.

2.Retain only the tag, removing the rest:

for eg:

<img src="url to image file" alt="picture" border="0" />

3.Now add the following script just prior to the closing />:

oncontextmenu='return false;'

4.As an alternative, you could also pop up a message:


oncontextmenu='alert("Copy Protected."); return false;'

Open Pdf,Doc,Docx files inside Same Browser Window using PHP

We usually try to include various types of files like pictures,documents,pdf files etc.For the picture files,you can directly upload the file to site and embed in your blog using <img> tag.

For word document files(.doc files),

you would need a Browser Plugin to do this .This will be really helpful for those who have no MICROSOFT OFFICE  installed in their system or without a valid license.

Browser Plugin

For word document files(.docx files),

There is a new Firefox plugin that allows you to open any docx file without any other software like MICROSOFT OFFICE 2007. Using this plugin, you can view docx file in original format and it is available for both Windows and Linux.

Browser Plugin

For Adobe pdf files(.pdf files),

Suppose,you have a online .PDF document and when a user clicks the link, you want it to open in the same window.Then include the following php code

<iframe id="myFrame" style="display:none" width="500" height="300"></iframe>
<input type="button" value="Open PDF" onclick = "openPdf()"/>
<script type="text/javascript">
function openPdf()
{
var omyFrame = document.getElementById("myFrame");
omyFrame.style.display="block";
omyFrame.src = "myFile.pdf";
}
</script>

You can do the same with asp.net with following piece of code
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("Content-Disposition","inline;filename=myfile.pdf");
Response.ContentType = "application/pdf";
Response.WriteFile("~/Hello.pdf");
Response.End();
}

Remember to add head to the Response stream and set inline to display the pdf file in the browser.