{"id":214,"date":"2012-10-18T20:15:05","date_gmt":"2012-10-18T20:15:05","guid":{"rendered":"http:\/\/vickistan.com\/?p=214"},"modified":"2012-10-18T20:15:05","modified_gmt":"2012-10-18T20:15:05","slug":"method-to-keep-private-libraries-private","status":"publish","type":"post","link":"https:\/\/vickistan.com\/?p=214","title":{"rendered":"Method to keep private libraries private"},"content":{"rendered":"<p>One method I have seen programmers (including myself) use to keep folks out of private libraries \/ include modules is to put a check in there.<\/p>\n<p>Easiest example:<\/p>\n<p>in index.php (or any script with permission to be called directly), this line, immediately after the &#8220;<?php\" tag\ndefine(\"VALID_REQ\", true);\n\nin your library files at the very top, immediately after the \"<?php\" tag\nif (!defined(\"VALID_REQ\"))\ndie (\"Unauthorized Access! This file cannot be directly accessed\");\n\nThe way that code works is if the site is accessed properly the way you intended, the variable \"VALID_REQ\" gets set. If someone calls a library directly that you have not set up to be accessed that way, PHP will kill itself immediately, and display an error to the user. At that point, no code will be executed and their attempt to hack your site will have failed.\n\nNote that the above advice is provided with no guarantees as we cannot guarantee any security or programming advice since they are outside our scope of support. Your mileage may vary, and we encourage you to speak with a security analyst or developer if you have further needs beyond what I have provided you.\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One method I have seen programmers (including myself) use to keep folks out of private libraries \/ include modules is to put a check in there. Easiest example: in index.php (or any script with permission to be called directly), this &hellip; <a href=\"https:\/\/vickistan.com\/?p=214\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-214","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=214"}],"version-history":[{"count":2,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/214\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/214\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}