{"id":6795,"date":"2014-03-16T05:07:33","date_gmt":"2014-03-15T18:07:33","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=6795"},"modified":"2014-03-16T05:07:33","modified_gmt":"2014-03-15T18:07:33","slug":"phphtmljavascript-password-protect-image-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/phphtmljavascript-password-protect-image-primer-tutorial\/","title":{"rendered":"PHP\/HTML\/Javascript Password Protect Image Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Windows\/MultiTasking\/Image_Password_Protected.html\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"PHP\/HTML\/Javascript Password Protect Image Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Windows\/MultiTasking\/PasswordProtectImage.jpg\" title=\"PHP\/HTML\/Javascript Password Protect Image Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP\/HTML\/Javascript Password Protect Image Primer Tutorial<\/p><\/div>\n<p>So you&#8217;ve seen the title of this blog post, but supposing you were to forget that, and link the concepts below &#8230; what would you have thought it was about?<\/p>\n<ul>\n<li>HTML\/Javascript onerror event for img tag<\/li>\n<li>(Image) file permissions at web server<\/li>\n<li>Prompt for information to verify &#8230; &#8220;password&#8221;<\/li>\n<li>PHP Asynchronous Processing via <a target=_blank title='exec' href='http:\/\/au1.php.net\/function.exec'>exec<\/a> and <a target=_blank title='cURL' href='https:\/\/php.net\/curl'>cURL<\/a> (perhaps)<\/li>\n<\/ul>\n<p>Imagine you may have come up with a number of ideas &#8230; maybe the way many blogs use <a target=_blank title='captcha' href='http:\/\/www.captcha.net\/'>captcha<\/a> to verify you are a real person? &#8230; or a quiz question you got wrong? &#8230; but no, we are talking about the components of a home-grown image (security) protection system at a website.   We are not pretending that this should replace any hosting arrangements your web hosting is capable of, like <a target=_blank title='web server password-protected directories (on apache' href='http:\/\/www.thesitewizard.com\/apache\/password-protect-directory.shtml'>password-protected directories<\/a> (on Apache (web server (using Linux))), for instance, but here we have a couple of &#8220;home-grown&#8221; ideas.   <\/p>\n<ol>\n<li>Not that impressive client solution &#8230; but simply one image with stringent file protection and the other identical image (content, but different name (or it can be a different place)) without &#8230; use HTML\/Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Windows\/MultiTasking\/Image_Password_Protected.html_GETME\" title=\"Image_Password_Protected.html\">Image_Password_Protected.html<\/a> &#8230; live run <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Windows\/MultiTasking\/Image_Password_Protected.html\" title=\"Image_Password_Protected.html live run\">here<\/a> (&#8220;password&#8221; you need to run this is <i>Windows_Home_Title_Bar.jpg<\/i>)<\/li>\n<li>More impressive client\/server solution (but there is more than one way to annoy cat lovers, if you know what I mean) &#8230; image has stringent file protection as its default condition, but will allow a user (who gets &#8220;password&#8221; correct) through for a few seconds, and continuing while the <a target=_blank title='cache information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Cache_%28computing%29'>cache<\/a> survives for them &#8230; use PHP\/HTML\/Javascript <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Windows\/MultiTasking\/Image_Password_Protected.php_GETME\" title=\"Image_Password_Protected.php\">Image_Password_Protected.php<\/a> &#8230; live run <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Windows\/MultiTasking\/Image_Password_Protected.php\" title=\"Image_Password_Protected.php live run\">here<\/a> (&#8220;password&#8221; you need to run this is <i>Windows_Home_Title_Bar.jpg<\/i>) &#8230; <i>this is very much &#8220;get you started code&#8221; in that it has hard-codings regarding the image name (and who&#8217;s to know if you are lucky enough to have <a target=_blank title='chortle, chortle' href='http:\/\/photo.net\/photodb\/photo?photo_id=1115004'>cURL<\/a> &#8230; would recommend it highly)<\/i><\/li>\n<\/ol>\n<p>Here are some helpful tutorials &#8230; thanks &#8230; below &#8230;<\/p>\n<ul>\n<li><a target=_blank title='HTML\/Javascript onerror event for img tag' href='http:\/\/www.w3schools.com\/jsref\/event_onerror.asp'>HTML\/Javascript onerror event for img tag<\/a><\/li>\n<li><a target=_blank title='(Image) file permissions at web server' href='http:\/\/www.comentum.com\/unix-osx-permissions.html'>(Image) file permissions at web server<\/a><\/li>\n<li><a target=_blank title='Prompt for information to verify ... \"password\"' href='http:\/\/www.w3schools.com\/jsref\/met_win_prompt.asp'>Prompt for information to verify &#8230; &#8220;password&#8221;<\/a><\/li>\n<li><a target=_blank title='PHP Asynchronous Processing via curl (perhaps)' href='http:\/\/www.davenewson.com\/dev\/methods-for-asynchronous-processes-in-php'>PHP Asynchronous Processing via cURL (perhaps)<\/a><\/li>\n<\/ul>\n<p>In solution 2 (the PHP one) you may see some <i>1 == 2<\/i>&#8216;ized code &#8230; that stuff for abandoned ideas &#8230; that idea was to have a recursive situation using iframe HTML tag &#8230; sometimes these iframe ideas work, but cannot recommend such approaches in a generic sense, and think <a target=_blank title='iframe information from w3schools ... thanks' href='http:\/\/www.w3schools.com\/tags\/tag_iframe.asp'>iframe<\/a> is generally under pressure &#8230; and just hope they never disappear.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d6795' onclick='var dv=document.getElementById(\"d6795\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=PHP\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d6795' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>So you&#8217;ve seen the title of this blog post, but supposing you were to forget that, and link the concepts below &#8230; what would you have thought it was about? HTML\/Javascript onerror event for img tag (Image) file permissions at &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/phphtmljavascript-password-protect-image-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,29,37],"tags":[85,177,205,284,422,572,576,587,590,652,707,865,905,932,997,1114,1319,1411],"class_list":["post-6795","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-operating-system","category-tutorials","tag-apache","tag-cache","tag-chmod","tag-curl","tag-file-permissions","tag-hosting","tag-html","tag-iframe","tag-image","tag-javascript","tag-linux","tag-onerror-event","tag-password-protected-directories","tag-php","tag-programming","tag-security","tag-tutorial","tag-web-server"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/6795"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=6795"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/6795\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=6795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=6795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=6795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}