{"id":1856,"date":"2012-10-14T19:28:28","date_gmt":"2012-10-14T19:28:28","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2012\/10\/14\/security-using-jexec\/"},"modified":"2021-08-16T23:34:03","modified_gmt":"2021-08-17T03:34:03","slug":"security-using-jexec","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/","title":{"rendered":"Adding security to a Joomla 3.1 template using JEXEC"},"content":{"rendered":"<p>Before we get into styling our Joomla 3.0 template, we will add the last piece of PHP code that we need, which is the checking of <strong>JEXEC<\/strong> variable.<\/p>\n<p>The concept of defining <a href=\"\/support\/edu\/joomla\/joomla-2-5\/defined-jexec-or-die\/\">JEXEC hasn&#8217;t changed since Joomla 2.5<\/a>. Simply put, JEXEC is a variable defined in your php files that prevents users on the web from accessing those files directly. Technically they can access your template&#8217;s index.php file through their browser, but execution of the file will end immediately because JEXEC is not defined within the template. If you don&#8217;t understand the technical reasons as to how this works, it&#8217;s not a big concern, but just make sure you have the code in place.<\/p>\n<h2>Use of JEXEC in Joomla 2.5 vs. Joomla 3.0<\/h2>\n<p>The following is how JEXEC is using in Joomla 2.5 vs. Joomla 3.0<\/p>\n<table class=\"article_table\">\n<tbody>\n<tr>\n<th>JEXEC in Joomla 2.5<\/th>\n<th>JEXEC in Joomla 3.0<\/th>\n<\/tr>\n<tr>\n<td>\n<pre class=\"code_block\">defined('_JEXEC') or die;<\/pre>\n<\/td>\n<td>\n<pre class=\"code_block\">defined('_JEXEC') or die;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As you can see, the use of JEXEC in the latest two versions of Joomla has not changed.<\/p>\n<h2>Adding JEXEC to a Joomla 3.0 Template<\/h2>\n<p>To incorporate JEXEC into <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/starting-template\/\">the Joomla 3.0 Template that we are creating<\/a>, we will simply add the necessary one line of code to the top of our index.php file. Before you can see the before and after of the top portion of the template&#8217;s index.php file.<\/p>\n<h3>Before<\/h3>\n<pre class=\"code_block\">&lt;?php\n\n$doc = JFactory::getDocument();\n\n$doc-&gt;addStyleSheet($this-&gt;baseurl . '\/media\/jui\/css\/bootstrap.min.css');\n$doc-&gt;addStyleSheet($this-&gt;baseurl . '\/media\/jui\/css\/bootstrap-responsive.css');\n$doc-&gt;addStyleSheet('templates\/' . $this-&gt;template . '\/css\/style.css');\n$doc-&gt;addScript('\/templates\/' . $this-&gt;template . '\/js\/main.js', 'text\/javascript');\n\n?&gt;<\/pre>\n<h3>After<\/h3>\n<pre class=\"code_block\">&lt;?php\n\n\n<span style=\"color: #ff0000;\"><strong>defined('_JEXEC') or die;\n\n\n<\/strong><\/span>$doc = JFactory::getDocument();\n\n$doc-&gt;addStyleSheet($this-&gt;baseurl . '\/media\/jui\/css\/bootstrap.min.css');\n$doc-&gt;addStyleSheet($this-&gt;baseurl . '\/media\/jui\/css\/bootstrap-responsive.css');\n$doc-&gt;addStyleSheet('templates\/' . $this-&gt;template . '\/css\/style.css');\n$doc-&gt;addScript('\/templates\/' . $this-&gt;template . '\/js\/main.js', 'text\/javascript');\n\n?&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Before we get into styling our Joomla 3.0 template, we will add the last piece of PHP code that we need, which is the checking of JEXEC variable. The concept of defining JEXEC hasn&#8217;t changed since Joomla 2.5. Simply put, JEXEC is a variable defined in your php files that prevents users on the web<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/\"> Read More ><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4403,94,4299],"tags":[4404],"class_list":["post-1856","post","type-post","status-publish","format-standard","hentry","category-joomla","category-joomla-3","category-security","tag-joomla-v3"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Adding security to a Joomla 3.1 template using JEXEC<\/title>\n<meta name=\"description\" content=\"In this tutorial, we&#039;ll show you how to add JEXEC to your Joomla 3.0 to help add a standard layer of security to your template.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adding security to a Joomla 3.1 template using JEXEC\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we&#039;ll show you how to add JEXEC to your Joomla 3.0 to help add a standard layer of security to your template.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2012-10-14T19:28:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T03:34:03+00:00\" \/>\n<meta name=\"author\" content=\"Brad Markle\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brad Markle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/\"},\"author\":{\"name\":\"Brad Markle\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\"},\"headline\":\"Adding security to a Joomla 3.1 template using JEXEC\",\"datePublished\":\"2012-10-14T19:28:28+00:00\",\"dateModified\":\"2021-08-17T03:34:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/\"},\"wordCount\":223,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"keywords\":[\"Joomla v3\"],\"articleSection\":[\"Joomla\",\"Joomla 3\",\"Security\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/\",\"name\":\"Adding security to a Joomla 3.1 template using JEXEC\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2012-10-14T19:28:28+00:00\",\"dateModified\":\"2021-08-17T03:34:03+00:00\",\"description\":\"In this tutorial, we'll show you how to add JEXEC to your Joomla 3.0 to help add a standard layer of security to your template.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Adding security to a Joomla 3.1 template using JEXEC\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\",\"name\":\"Brad Markle\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Adding security to a Joomla 3.1 template using JEXEC","description":"In this tutorial, we'll show you how to add JEXEC to your Joomla 3.0 to help add a standard layer of security to your template.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/","og_locale":"en_US","og_type":"article","og_title":"Adding security to a Joomla 3.1 template using JEXEC","og_description":"In this tutorial, we'll show you how to add JEXEC to your Joomla 3.0 to help add a standard layer of security to your template.","og_url":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2012-10-14T19:28:28+00:00","article_modified_time":"2021-08-17T03:34:03+00:00","author":"Brad Markle","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Brad Markle","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/"},"author":{"name":"Brad Markle","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf"},"headline":"Adding security to a Joomla 3.1 template using JEXEC","datePublished":"2012-10-14T19:28:28+00:00","dateModified":"2021-08-17T03:34:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/"},"wordCount":223,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"keywords":["Joomla v3"],"articleSection":["Joomla","Joomla 3","Security"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/","url":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/","name":"Adding security to a Joomla 3.1 template using JEXEC","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2012-10-14T19:28:28+00:00","dateModified":"2021-08-17T03:34:03+00:00","description":"In this tutorial, we'll show you how to add JEXEC to your Joomla 3.0 to help add a standard layer of security to your template.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/security-using-jexec\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Adding security to a Joomla 3.1 template using JEXEC"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf","name":"Brad Markle","url":"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=1856"}],"version-history":[{"count":5,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1856\/revisions"}],"predecessor-version":[{"id":85515,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/1856\/revisions\/85515"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=1856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=1856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=1856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}