diff --git a/.htaccess b/.htaccess index 4b51721..7ac0200 100644 --- a/.htaccess +++ b/.htaccess @@ -3,3 +3,175 @@ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?page=$1 [L] + + +# Insert filters / compress text, html, javascript, css, xml: +# mod_deflate can be used for Apache v2 and later and is the recommended GZip mechanism to use +AddOutputFilterByType DEFLATE text/plain +AddOutputFilterByType DEFLATE text/javascript +AddOutputFilterByType DEFLATE text/html +AddOutputFilterByType DEFLATE text/xml +AddOutputFilterByType DEFLATE text/css +AddOutputFilterByType DEFLATE text/vtt +AddOutputFilterByType DEFLATE text/x-component +AddOutputFilterByType DEFLATE application/xml +AddOutputFilterByType DEFLATE application/xhtml+xml +AddOutputFilterByType DEFLATE application/rss+xml +AddOutputFilterByType DEFLATE application/js +AddOutputFilterByType DEFLATE application/javascript +AddOutputFilterByType DEFLATE application/x-javascript +AddOutputFilterByType DEFLATE application/x-httpd-php +AddOutputFilterByType DEFLATE application/x-httpd-fastphp +AddOutputFilterByType DEFLATE application/atom+xml +AddOutputFilterByType DEFLATE application/json +AddOutputFilterByType DEFLATE application/ld+json +AddOutputFilterByType DEFLATE application/vnd.ms-fontobject +AddOutputFilterByType DEFLATE application/x-font-ttf +AddOutputFilterByType DEFLATE application/font-sfnt +AddOutputFilterByType DEFLATE application/x-web-app-manifest+json +AddOutputFilterByType DEFLATE font/opentype +AddOutputFilterByType DEFLATE font/otf +AddOutputFilterByType DEFLATE font/ttf +AddOutputFilterByType DEFLATE font/sfnt +AddOutputFilterByType DEFLATE image/svg+xml +AddOutputFilterByType DEFLATE image/x-icon + +# Exception: Images +SetEnvIfNoCase REQUEST_URI \.(?:gif|jpg|jpeg|png)$ no-gzip dont-vary + +# Drop problematic browsers +BrowserMatch ^Mozilla/4 gzip-only-text/html +BrowserMatch ^Mozilla/4\.0[678] no-gzip +BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html + +# Make sure proxies don't deliver the wrong content + +Header append Vary User-Agent env=!dont-vary + + + + +# mod_gzip is an external extension and last updated 2015, so +# if available please use mod_deflate instead +# If you are stuck on Apache v1.3 you can use mod_zip to enable Gzip +# as mod_deflate is available for Apache v2 or later only. + + mod_gzip_on Yes + mod_gzip_dechunk Yes + mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ + mod_gzip_item_include handler ^cgi-script$ + mod_gzip_item_include mime ^text/.* + mod_gzip_item_include mime ^application/x-javascript.* + mod_gzip_item_exclude mime ^image/.* + mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* + + + +## EXPIRES CACHING ## + +ExpiresActive On +ExpiresDefault "access plus 1 week" + +ExpiresByType text/css "access plus 1 month" + +ExpiresByType application/atom+xml "access plus 1 hour" +ExpiresByType application/rdf+xml "access plus 1 hour" +ExpiresByType application/rss+xml "access plus 1 hour" + +ExpiresByType application/json "access plus 0 seconds" +ExpiresByType application/ld+json "access plus 0 seconds" +ExpiresByType application/schema+json "access plus 0 seconds" +ExpiresByType application/vnd.geo+json "access plus 0 seconds" +ExpiresByType application/xml "access plus 0 seconds" +ExpiresByType text/xml "access plus 0 seconds" + +ExpiresByType image/x-icon "access plus 1 month" +ExpiresByType image/vnd.microsoft.icon "access plus 1 month" + +ExpiresByType text/html "access plus 1 minute" + +ExpiresByType text/javascript "access plus 1 month" +ExpiresByType text/x-javascript "access plus 1 month" +ExpiresByType application/javascript "access plus 1 months" +ExpiresByType application/x-javascript "access plus 1 months" + +ExpiresByType image/jpg "access plus 1 month" +ExpiresByType image/jpeg "access plus 1 month" +ExpiresByType image/gif "access plus 1 month" +ExpiresByType image/png "access plus 1 month" +ExpiresByType image/svg+xml "access plus 1 month" +ExpiresByType image/bmp "access plus 1 month" +ExpiresByType image/webp "access plus 1 month" + +ExpiresByType audio/ogg "access plus 1 month" + +ExpiresByType video/mp4 "access plus 1 month" +ExpiresByType video/ogg "access plus 1 month" +ExpiresByType video/webm "access plus 1 month" + +ExpiresByType text/plain "access plus 1 month" +ExpiresByType text/x-component "access plus 1 month" + +ExpiresByType application/manifest+json "access plus 1 week" +ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" +ExpiresByType text/cache-manifest "access plus 0 seconds" + +ExpiresByType application/pdf "access plus 1 month" + +ExpiresByType application/x-shockwave-flash "access plus 1 month" + +ExpiresByType application/vnd.ms-fontobject "access plus 1 month" +ExpiresByType font/eot "access plus 1 month" +ExpiresByType font/opentype "access plus 1 month" +ExpiresByType application/x-font-ttf "access plus 1 month" +ExpiresByType application/font-woff "access plus 1 month" +ExpiresByType application/font-woff2 "access plus 1 month" +ExpiresByType application/x-font-woff "access plus 1 month" +ExpiresByType font/woff "access plus 1 month" + + +## EXPIRES CACHING ## + + +#Alternative caching using Apache's "mod_headers", if it's installed. +#Caching of common files - ENABLED + + +# 1 Month + +Header set Cache-Control "max-age=2592000, public" + + +# 2 DAYS + +Header set Cache-Control "max-age=172800, public, must-revalidate" + + +# 2 HOURS + +Header set Cache-Control "max-age=7200, must-revalidate" + + + + + + + + Header append Vary: Accept-Encoding + + + +# Set Keep Alive Header +# This *just* sets the header - maybe your hoster is not allowing this feature +# Please check if it is working with tools like http://www.webpagetest.org + + Header set Connection keep-alive + + +# If your server don't support ETags deactivate with "None" (and remove header) + + + Header unset ETag + + FileETag None + \ No newline at end of file diff --git a/README.md b/README.md index d5966dc..3602fb5 100644 --- a/README.md +++ b/README.md @@ -29,19 +29,16 @@ Local Disc C: -> xampp -> htdocs -> 'ytronic' ### Howto create Pages and Menus -- Go to `ytronic -> yt-content` and create a file `webpage.php` inside +- Go to `ytronic -> yt-content`, clone `faqs.php`, rename to `webpage.php` and edit the title, content, metas, etc... -- Open `ytronic -> yt-template -> functions.php` and go to `line 101` and add this: +- Open `ytronic -> yt-template -> nav-menu.php` and go to `line 11` and add this: ```php -'webpage' => array( - 'menu_name' => 'Web Page', - 'page_title' => 'Web Page title', - 'page_description' => 'Web Page description', +'webpage' => 'Webpage', ), ``` -- Refresh your browser and a new menu should be appear +- Refresh your browser and a new menu item should be appear License ------- diff --git a/robots.txt b/robots.txt index 235f7aa..0f69ca0 100644 --- a/robots.txt +++ b/robots.txt @@ -1,2 +1,2 @@ User-agent: * -Disallow / +Allow / diff --git a/screenshot.png b/screenshot.png index 1842abb..08fafba 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/yt-config.php b/yt-config.php index d868c17..8c4e2c0 100644 --- a/yt-config.php +++ b/yt-config.php @@ -8,14 +8,15 @@ function yt_config( $opt = '' ) { $settings = array( - 'site_lang' => 'en', /** Website language **/ - 'site_name' => 'Ytronic', /** Website name **/ - 'site_descript' => 'Ytronic description', /** Website description **/ - 'site_url' => 'http://localhost/ytronic/', /** Website url **/ - 'pretty_url' => false, /** Convert url "/?page=contact" to "/contact" **/ - 'template_dir' => 'yt-template', /** Template directory name **/ - 'content_dir' => 'yt-content', /** Pages directory name **/ - 'version' => 'v2.1.0', /** Ytronic app version **/ + 'site_lang' => 'en', /** Website language **/ + 'site_name' => 'Ytronic', /** Website name **/ + 'site_descript' => 'Faster PHP Website', /** Website description **/ + 'site_url' => 'http://localhost/ytronic/', /** Website url **/ + 'pretty_url' => true, /** Convert url "/?page=contact" to "/contact" **/ + 'allow_search_engine' => true, /** Allow search engines to indexing this website. Warning!!! -> Edit robots.txt file **/ + 'template_dir' => 'yt-template', /** Template directory name **/ + 'content_dir' => 'yt-content', /** Pages directory name **/ + 'version' => 'v3.1.0', /** Ytronic app version **/ ); return isset($settings[$opt]) ? $settings[$opt] : null; @@ -63,4 +64,4 @@ function site_url() } if ( ! defined( 'IMGURI' ) ) { define ( 'IMGURI', TMPLURI .'/assets/images' ); -} \ No newline at end of file +} diff --git a/yt-content/404.php b/yt-content/404.php index 4bffc8d..d6be085 100644 --- a/yt-content/404.php +++ b/yt-content/404.php @@ -3,7 +3,17 @@ exit; // Exit if accessed directly. } -function yt_page_content() +function YTMetaRobots() +{ + echo YTIndexingSearchEngines('noindex','nofollow'); +} + +function YTPageTitle() +{ + echo '404 Page not found - Ytronic - Advanced and Faster PHP Website'; +} + +function YTLoadPageContent() { ob_start(); // Page content to buffer ?> diff --git a/yt-content/contact.php b/yt-content/contact.php index f735544..02c6390 100644 --- a/yt-content/contact.php +++ b/yt-content/contact.php @@ -3,7 +3,27 @@ exit; // Exit if accessed directly. } -function yt_page_content() +function YTMetaRobots() +{ + echo YTIndexingSearchEngines('index','nofollow'); +} + +function YTPageTitle() +{ + echo 'Contact - Ytronic - Advanced and Faster PHP Website'; +} + +function YTPageDescription() +{ + echo ''; +} + +function YTPageKeywords() +{ + echo ''; +} + +function YTLoadPageContent() { ob_start(); // Page content to buffer ?> diff --git a/yt-content/cookies.php b/yt-content/cookies.php index 5ad7b90..cf85ba8 100644 --- a/yt-content/cookies.php +++ b/yt-content/cookies.php @@ -3,7 +3,27 @@ exit; // Exit if accessed directly. } -function yt_page_content() +function YTMetaRobots() +{ + echo YTIndexingSearchEngines('index','nofollow'); +} + +function YTPageTitle() +{ + echo 'Cookies - Ytronic - Advanced and Faster PHP Website'; +} + +function YTPageDescription() +{ + echo ''; +} + +function YTPageKeywords() +{ + echo ''; +} + +function YTLoadPageContent() { ob_start(); // Page content to buffer ?> diff --git a/yt-content/faqs.php b/yt-content/faqs.php index 4b472f4..97312a7 100644 --- a/yt-content/faqs.php +++ b/yt-content/faqs.php @@ -3,7 +3,27 @@ exit; // Exit if accessed directly. } -function yt_page_content() +function YTMetaRobots() +{ + echo YTIndexingSearchEngines('index','nofollow'); +} + +function YTPageTitle() +{ + echo 'FAQs - Ytronic - Advanced and Faster PHP Website'; +} + +function YTPageDescription() +{ + echo ''; +} + +function YTPageKeywords() +{ + echo ''; +} + +function YTLoadPageContent() { ob_start(); // Page content to buffer ?> diff --git a/yt-content/help.php b/yt-content/help.php index c8c9b4a..7ffc6a1 100644 --- a/yt-content/help.php +++ b/yt-content/help.php @@ -3,7 +3,27 @@ exit; // Exit if accessed directly. } -function yt_page_content() +function YTMetaRobots() +{ + echo YTIndexingSearchEngines('index','nofollow'); +} + +function YTPageTitle() +{ + echo 'Help - Ytronic - Advanced and Faster PHP Website'; +} + +function YTPageDescription() +{ + echo ''; +} + +function YTPageKeywords() +{ + echo ''; +} + +function YTLoadPageContent() { ob_start(); // Page content to buffer ?> diff --git a/yt-content/home.php b/yt-content/home.php index 4c9d209..7b59fca 100644 --- a/yt-content/home.php +++ b/yt-content/home.php @@ -3,7 +3,27 @@ exit; // Exit if accessed directly. } -function yt_page_content() +function YTMetaRobots() +{ + echo YTIndexingSearchEngines('index','follow'); +} + +function YTPageTitle() +{ + echo 'Ytronic - Advanced and Faster PHP Website'; +} + +function YTPageDescription() +{ + echo ''; +} + +function YTPageKeywords() +{ + echo ''; +} + +function YTLoadPageContent() { ob_start(); // Page content to buffer ?> diff --git a/yt-content/services.php b/yt-content/services.php index 7134a04..95d0cb9 100644 --- a/yt-content/services.php +++ b/yt-content/services.php @@ -3,7 +3,27 @@ exit; // Exit if accessed directly. } -function yt_page_content() +function YTMetaRobots() +{ + echo YTIndexingSearchEngines('index','nofollow'); +} + +function YTPageTitle() +{ + echo 'Services - Ytronic - Advanced and Faster PHP Website'; +} + +function YTPageDescription() +{ + echo ''; +} + +function YTPageKeywords() +{ + echo ''; +} + +function YTLoadPageContent() { ob_start(); // Page content to buffer ?> diff --git a/yt-template/assets/css/style.css b/yt-template/assets/css/style.css index 9ab1606..18b5bad 100644 --- a/yt-template/assets/css/style.css +++ b/yt-template/assets/css/style.css @@ -4,7 +4,7 @@ * Author: Yonox * Author URI: https://github.com/elyonox * Description: PHP Website designed for multipurpose objective. - * Version: 2.1.0 + * Version: 3.1.0 * License: GNU General Public License v2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html */ diff --git a/yt-template/footer.php b/yt-template/footer.php index 0adf56b..33e7574 100644 --- a/yt-template/footer.php +++ b/yt-template/footer.php @@ -5,7 +5,6 @@ if ( ! defined( 'YTABPATH' ) ) { exit; // Exit if accessed directly. } ?> - - - + \ No newline at end of file diff --git a/yt-template/functions.php b/yt-template/functions.php index 28cefa1..5314bfa 100644 --- a/yt-template/functions.php +++ b/yt-template/functions.php @@ -28,6 +28,26 @@ function site_name() echo yt_config( 'site_name' ); } +/** + * Site description. + */ +function YTSiteDescript() +{ + echo yt_config( 'site_descript' ); +} + +/** + * Indexing pages to search engines or not. + */ +function YTIndexingSearchEngines( $index = 'index', $follow = 'follow') +{ + $meta_robots = "\n\t".''."\n"; + $block_robots = "\n\t".''."\n"; + $allow_sengine = yt_config('allow_search_engine' ) ? $meta_robots : $block_robots; + + return $allow_sengine; +} + /** * Create link when pretty_url is active. */ @@ -42,7 +62,7 @@ function make_link( $link ) /** * Load header styles. */ -function load_styles() +function YTLoadStyles() { $hscripts = array( '', @@ -59,7 +79,7 @@ function load_styles() /** * Load footer scripts. */ -function load_scripts() +function YTLoadScripts() { $fscripts = array( '', @@ -74,78 +94,19 @@ function load_scripts() } } -/** - * Retrieve pages meta data and nav_menu items. - */ -function page_metas( $page_uri = null, $meta_type ) -{ - $site_pages = array( - // home menu item with page title and meta description - '/' => array( - 'menu_name' => 'Home', - 'page_title' => 'Home page title', - 'page_description' => 'Home page description', - ), - // service menu item with page title and meta description - 'services' => array( - 'menu_name' => 'Services', - 'page_title' => 'Services page title', - 'page_description' => 'Services page description', - ), - // contact menu item with page title and meta description - 'contact' => array( - 'menu_name' => 'Contact', - 'page_title' => 'Contact page title', - 'page_description' => 'Contact page description', - ), - - ); - - $items_nav_menu = []; - - foreach ( $site_pages as $pguri => $menu_names ) - { - $items_nav_menu[$pguri] = $menu_names['menu_name']; - } - - if ( $meta_type == 'nav_menu' ) - { - // return nav_menu array - return $items_nav_menu; - } - - if ( $page_uri ) - { - // query_str() without trailing end slash - $qstring = query_str() !== '/' ? rtrim(query_str(),"/") : query_str(); - - if ( array_key_exists($qstring, $site_pages) ) { - $return_metas = $site_pages[$qstring][$meta_type]; - } else { - $page_path = getcwd() . '/' . yt_config('content_dir') . '/' . $qstring .'.php'; - if ( file_exists( $page_path ) ) { - $return_metas = ucfirst(str_replace('-', ' ', $qstring)); - } else { - $return_metas = '404 Error - Page not found'; - } - } - // return page title tag and description - return $return_metas; - } -} - /** * Website navigation. */ function nav_menu() { $nav_menu = ''; - $nav_items = page_metas(false,'nav_menu'); + + include yt_config('template_dir') .'/nav-menu.php'; foreach ( $nav_items as $uri => $name ) { - $class = query_str() == $uri ? ' active' : ''; - + $class = query_str() == $uri .'/' || query_str() == $uri ? ' active' : ''; + $nav_menu .= "\t\t\t\t".''. $name .''."\n"; } @@ -155,7 +116,7 @@ function nav_menu() /** * Load page content. */ -function yt_load_pages() +function YTLoadPages() { $req_page = isset($_GET['page']) ? $_GET['page'] : 'home'; @@ -185,7 +146,7 @@ function footer_info() /** * Load page header. */ -function yt_header() +function YTLoadHeader() { include_once YTTMPL .'/header.php'; } @@ -193,7 +154,7 @@ function yt_header() /** * Load page footer. */ -function yt_footer() +function YTLoadFooter() { include_once YTTMPL .'/footer.php'; } diff --git a/yt-template/header.php b/yt-template/header.php index e3fbf58..57b9b2b 100644 --- a/yt-template/header.php +++ b/yt-template/header.php @@ -8,20 +8,29 @@ - - - <?php echo page_metas( query_str(), 'page_title' ); ?> | <?php site_name(); ?> - + + <?php if(function_exists('YTPageTitle')){YTPageTitle();}else{site_name();echo " - ";YTSiteDescript();} ?> - - + "> + - + // Load meta SchemaOrg if function exists on the page + if (function_exists('YTSchemaOrg')){YTSchemaOrg();} ?>
diff --git a/yt-template/nav-menu.php b/yt-template/nav-menu.php new file mode 100644 index 0000000..c480d82 --- /dev/null +++ b/yt-template/nav-menu.php @@ -0,0 +1,12 @@ + 'Home', + 'services' => 'Services', + 'contact' => 'Contact', + +); diff --git a/yt-template/template.php b/yt-template/template.php index b3422c0..08122c3 100644 --- a/yt-template/template.php +++ b/yt-template/template.php @@ -6,13 +6,13 @@ exit; // Exit if accessed directly. } -yt_load_pages(); +YTLoadPages(); -yt_header(); +YTLoadHeader(); -if ( function_exists( 'yt_page_content' ) ) +if ( function_exists( 'YTLoadPageContent' ) ) { - yt_page_content(); + YTLoadPageContent(); } else { $noContent = '
'; $noContent .= '

NO Content...

'; @@ -22,4 +22,4 @@ echo $noContent; } -yt_footer(); +YTLoadFooter();