Advertisement
pbowers

UserSpice: header.php - allow custom per-page CSS in <head>

Sep 19th, 2016
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.45 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. /*
  4. UserSpice 4
  5. An Open Source PHP User Management System
  6. by the UserSpice Team at http://UserSpice.com
  7.  
  8. This program is free software: you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation, either version 3 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. ?>
  22. <?php require_once $abs_us_root.$us_url_root.'users/helpers/helpers.php'; ?>
  23. <?php require_once $abs_us_root.$us_url_root.'users/includes/user_spice_ver.php'; ?>
  24. <?php
  25. //check for a custom page
  26. $currentPage = currentPage();
  27. if(file_exists($abs_us_root.$us_url_root.'usersc/'.$currentPage)){
  28.     if(currentFolder()!= 'usersc'){
  29.         Redirect::to($us_url_root.'usersc/'.$currentPage);
  30.     }
  31. }
  32.  
  33. $db = DB::getInstance();
  34. $settingsQ = $db->query("Select * FROM settings");
  35. $settings = $settingsQ->first();
  36. if ($settings->site_offline==1){
  37.     die("The site is currently offline.");
  38. }
  39.  
  40. if ($settings->force_ssl==1){
  41.     if (!isset($_SERVER['HTTPS']) || !$_SERVER['HTTPS']) {
  42.         // if request is not secure, redirect to secure url
  43.         $url = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
  44.         Redirect::to($url);
  45.         exit;
  46.     }
  47. }
  48.  
  49. //if track_guest enabled AND there is a user logged in
  50. if($settings->track_guest == 1 && $user->isLoggedIn()){
  51.     if ($user->isLoggedIn()){
  52.         $user_id=$user->data()->id;
  53.     }else{
  54.         $user_id=0;
  55.     }
  56.     new_user_online($user_id);
  57.  
  58. }
  59. ?>
  60. <!DOCTYPE html>
  61. <html lang="en">
  62. <head>
  63.     <meta charset="utf-8">
  64.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  65.     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  66.     <meta name="description" content="">
  67.     <meta name="author" content="">
  68.  
  69.     <?php
  70.     if(file_exists($abs_us_root.$us_url_root.'usersc/includes/head_tags.php')){
  71.         require_once $abs_us_root.$us_url_root.'usersc/includes/head_tags.php';
  72.     }
  73.     ?>
  74.  
  75.     <title><?=$settings->site_name;?></title>
  76.  
  77.     <!-- Bootstrap Core CSS -->
  78.     <!-- AKA Primary CSS -->
  79.     <link href="<?=$us_url_root?><?=str_replace('../','',$settings->us_css1);?>" rel="stylesheet">
  80.  
  81.     <!-- Template CSS -->
  82.     <!-- AKA Secondary CSS -->
  83.     <link href="<?=$us_url_root?><?=str_replace('../','',$settings->us_css2);?>" rel="stylesheet">
  84.  
  85.     <!-- If you are loading xyz.php and a script xyz.css exists, load it !-->
  86.     <?php
  87.     $mycss = $us_url_root.'usersc/css/'.basename($_SERVER['PHP_SELF'], '.php').'.css';
  88.     #echo "mycss=$mycss abs_us_root=$abs_us_root<br />\n";
  89.     if (file_exists($abs_us_root.$mycss)) {
  90.         echo "<link href=\"$mycss\" rel=\"stylesheet\">\n";
  91.     }
  92.     ?>
  93.  
  94.     <!-- Your Custom CSS Goes Here!-->
  95.     <link href="<?=$us_url_root?><?=str_replace('../','',$settings->us_css3);?>" rel="stylesheet">
  96.  
  97.     <!-- Custom Fonts -->
  98.     <link href="<?=$us_url_root?>users/fonts/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  99.  
  100.     <!-- Custom inline styles !-->
  101.     <?php
  102.     if (@$HeaderStyles) {
  103.         echo "<style>\n";
  104.         foreach ((array)$HeaderStyles as $style)
  105.             echo "$style\n";
  106.         echo "</style>\n";
  107.     }
  108.     if (@$Headers) {
  109.         foreach ((array)$Headers as $line)
  110.             echo "$line\n";
  111.     }
  112.     ?>
  113.  
  114. </head>
  115.  
  116. <body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement