Why is my css file not being read in yii mailer? - html

I have an email controller with the following function inside
public function actionCreate()
{
$invoice_number_1 = Yii::$app->request->post('invoice_number_1');
$part_number_1 = Yii::$app->request->post('part_number_1');
$quantity_1 = Yii::$app->request->post('quantity_1');
$reason_code_1 = Yii::$app->request->post('reason_code_1');
// There are more of these but they work fine
Yii::$app->mailer->compose(
[
'html'=>'email/myfile.php'
],
[
'invoice_number_1' => $invoice_number_1,
'part_number_1' => $part_number_1,
'quantity_1' => $quantity_1,
'reason_code_1' => $reason_code_1,
// There are more of these but they work fine
])
->setFrom([Yii::$app->params['fromEmailAddress'] => Yii::$app->params['fromEmailName']])
// There are more of these but they work fine
->send();
}
The html file this links to is identical to the one is the same as in the example on the yii website but with two content security policy meta links and a link to my css as follows:
<?php
use yii\helpers\Html;
/* #var $this \yii\web\View view component instance */
/* #var $message \yii\mail\MessageInterface the message being composed */
/* #var $content string main view render result */
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
<meta http-equiv="Content-Security-Policy" context="style-src 'self' 'unsafe-inline'" />
<meta http-equiv="Content-Security-Policy" content="style-src-elem 'self' 'unsafe-inline'">
<link rel="stylesheet" type="text/css" href="../credit_request/credit_request.css" />
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
I have also changed the html file to just
<?php
use yii\helpers\Html;
/* #var $this \yii\web\View view component instance */
/* #var $message \yii\mail\MessageInterface the message being composed */
/* #var $content string main view render result */
?>
<?php $this->beginPage() ?>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
<?php $this->endPage() ?>
and it gives the same result.
The email/index.php page is as follows
<!DOCTYPE html >
<html >
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Security-Policy" content="style-src 'self' 'unsafe-inline'">
<meta http-equiv="Content-Security-Policy" content="style-src-elem 'self' 'unsafe-inline'">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="./credit_request.css" />
</head>
<body>
<div class="container_1">
<span class="numbers_1" ><?php echo strtoupper($invoice_number_1) ?>   -   <?php echo strtoupper($part_number_1) ?>   x   <?php echo strtoupper($quantity_1) ?>  </span>
<span class="reason_code_1"><?php echo strtoupper($reason_code_1)?></span>
</div>
</body>
</html>
When I send an email I get the following error referring to the link in the html file:
Refused to load the stylesheet 'http://192.168.0.90/email/index.css' because it violates the following Content Security Policy directive: "style-src 'unsafe-inline'". Note that 'style-src-elem' was not explicitly set, so 'style-src' is used as a fallback.
I also get the following three errors referring to the link in the email/index.php file:
The Content Security Policy 'style-src 'self' 'unsafe-inline'' was delivered via a element outside the document's , which is disallowed. The policy has been ignored.
The Content Security Policy 'style-src-elem 'self' 'unsafe-inline'' was delivered via a element outside the document's , which is disallowed. The policy has been ignored.
Refused to load the stylesheet 'http://192.168.0.90/otrs/index.css' because it violates the following Content Security Policy directive: "style-src 'unsafe-inline'". Note that 'style-src-elem' was not explicitly set, so 'style-src' is used as a fallback.
My css file is just
.container_1 {
background-color: red;
}
How do I get the css to be recognised?

Related

Yii2 Assest Bundle not loading CSS in the view

I am facing an issue. I have custom Module in which i am trying to load CSS and JS by AppAsset but its not loading.
In my Module i have layouts folder in which i am trying to access the appasset and registering the view but its not loading. Even the asset bundle shows that assests are being loaded
Tell me what i am doing wrong. The code is as follows
namespace app\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = '#webroot';
public $baseUrl = '#web';
public $css = [
'css/site.css',
'css/bootstrap-reset.css',
'css/style.css',
'css/style-responsive.css',
];
public $js = [
'js/jquery.js',
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
my view file is as follows
<?php
use yii\helpers\Html;
use app\assets\AppAsset;
AppAsset::register($this);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="ThemeBucket">
<link rel="shortcut icon" href="images/favicon.png">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
<!--Core CSS -->
</head>
<body class="login-body">
<?php $this->beginBody() ?>
<?php $this->endBody() ?>
</body>
</html>
But the css is not loaded at all and i cant see any of the css which i defined in Asset Bundle
Function <?php $this->head() ?> just adds a placeholder where all head meta tags, styles, scripts must be placed.
When <?php $this->endPage() ?> is called it replaces placeholder with registered meta tags, styles, scripts, etc.

Injecting meta tag on certain pages with directive

I have an application where I want to inject a smartBanner meta tag, but only on certain pages.
On my index page I have:
<!DOCTYPE html>
<html ng-app="ngBoilerplate" ng-controller="AppCtrl">
<head>
<title ng-bind="pageTitle"></title>
<!-- add smart banner to select pages through smartBanner directive -->
<smart-banner></smart-banner>
</head>
<body>
<ui-view></ui-view>
</body>
</html>
I have a directive:
angular.module('boh.components.smartBanner', [])
.directive('smartBanner', function(){
return {
restrict: "E",
template: '<meta name="apple-itunes-app" content="app-id=1080200000"></meta>',
replace: true
} ;
});
My question is, do I simply call the directive by injecting the directive into my other page controllers?
I discovered the best way to deal with this was to work through the PHP wrapper for the app.
I ended up with something like this:
<?php
$urls = array("/app/explore", "/app/dashboard", "app/members", "/app/account-settings", "/app/jobs");
foreach ($urls as $key => $value) {
if( $_SERVER['REQUEST_URI'] === $value ) { ?>
<meta name="apple-itunes-app" content="app-id=########">
<?php }
}
?>

Showing different links depending on who is logged in

I'm trying to create a few links that change depending on who is logged in, for example when a user logs in, log in changes to log out, just started making the if statements but they dont seem to recognise the sessions. Can anyone see an issue? Excuse the poor layout, been playing around.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<?php
session_start();
?>
<link rel="stylesheet" type="text/css" href="skeleton.css" />
<link rel="stylesheet" type="text/css" href="normalize.css" />
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<title>Assignment1</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/skeleton.css">
<!-- Favicon
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="icon" type="image/png" href="images/favicon.png">
</head>
<body>
<!-- Primary Page Layout
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<?php
if (isset($_SESSION['userlogged']))
{
?>
<div class="container">
<div class="row">
<center><h4>Basic Requirements</h4>
<pre>
Logout Registration Contact Search
</pre>
</div>
</center>
</div>
<?php
}
else if (isset($_SESSION['adminlogged']))
{
}
else
{
?>
<div class="container">
<div class="row">
<center><h4>Basic Requirements</h4>
<pre>
Logout Registration Contact Search
</pre>
</div>
</center>
</div>
<?php
}
?>
<!-- End Document
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
</body>
</html>
Loginsubmit.php
<?php
session_start();
?>
<font face="ClearSans-Thin">
<font color="lightgray">
<?php
include 'connection.php';
include 'loginform.php';
?>
<center>
<?php
if (isset($_POST['submit']))
{
$user = $_POST['username'];
$pass = $_POST['password'];
//Counts up how many matches there are in the database
$query = "SELECT COUNT(*) AS cnt FROM users WHERE Username ='" . mysqli_real_escape_string($connection, $user) . "'AND Password='" . mysqli_real_escape_string($connection, $pass). "'";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_assoc($result);
/*$queryadmin = "SELECT COUNT(*) AS cnt FROM admin WHERE Username ='" . mysqli_real_escape_string($connection, $user) . "'AND Password='" . mysqli_real_escape_string($connection, $pass). "'";*/
/*$resultadmin = mysqli_query($connection, $queryadmin);*/
/*$rowadmin = mysqli_fetch_assoc($resultadmin);*/
//If count is more than 0, log user in.
if ($row["cnt"] > 0)
{
$_SESSION["userlogged"] = $user;
echo "Logged in - Press the home button to return to the homepage";
}
else if ($rowadmin["cnt"] > 0 )
{
$_SESSION["adminlogged"] = $user;
echo "Logged in - Press the home button to return to the homepage";
}
else
{
echo 'Not a valid login';
}
}
?>
your index page needs the session_start(); to read session variables
session_start();
echo $_SESSION['userlogged'];

Crazy 403 Forbidden Error on Wordpress Site

Just installed a new theme on my site: www.rivertam.co
For some reason I keep getting this 403 Forbidden error at the top of it.
I've tried removing the htaccess file like some have suggested, nothing happens. Really no idea why it's there.
Can anyone give me any suggestions?
Happy to paste any PHP you may need. Just let me know!
Header.php code:
<!DOCTYPE html>
>
>
>
>
<title><?php wp_title( ' ', true, 'right' ); /* filtered in libraries/filers.php */ ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<link rel="shortcut icon" href="<?php echo get_template_directory_uri(); ?>/favicon.gif" />
<link rel="apple-touch-icon" href="<?php echo get_template_directory_uri(); ?>/apple-touch-icon.png" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
<?php
// See functions.php for CSS / JAVASCRIPT information
wp_head(); // do not remove this
?>
>
<div id="branding_wrap">
<header id="branding">
<div class="container">
<?php
// Grab the column settings from theme settings to determine the logo/menu container sizes
$logo_columns = $menu_columns = "eight";
$header_layout = cudazi_get_option( 'header_layout', 'eight|eight' );
$header_layout = explode('|', $header_layout);
if ( is_array( $header_layout ) ) {
$logo_columns = $header_layout[0];
$menu_columns = $header_layout[1];
}
?>
<hgroup class="<?php echo $logo_columns; ?> columns">
<h1 id="logo"><?php echo cudazi_get_logo(); ?></h1>
<?php if ( ! cudazi_get_option( 'disable_tagline', false ) ) { ?>
<h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
<?php } ?>
</hgroup>
<nav class="<?php echo $menu_columns; ?> columns" id="navigation" role="navigation">
<?php wp_nav_menu( array( 'menu_class' => 'sf-menu clearfix', 'theme_location' => 'primary', 'fallback_cb' => 'cudazi_menu_fallback' ) ); ?>
<?php echo cudazi_alternate_menu( array( 'menu_name' => 'primary', 'display' => 'select' ) ); ?>
</nav>
</div><!--//container (skeleton) -->
</header><!--//header-->
</div>
<section id="main">
Do you include any other files programmativally? (AJAX?)
If yes I would first check permissions! Files have to be world-readable (in normal setups) to be delivered through web...

Switching to Codeigniter HMVC - Undefined functions?

I have setup a fresh install of codeigniter 2x and modular extensions (https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home)
It is my first time using HMVC, the decision to move from MVC to HMVC was to give myself more control of my login, admin, and members areas.
I have created my first controller in HMVC like so....
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends MX_Controller {
function __construct()
{
parent::__construct();
$this->load->model('Content_model');
}
public function index()
{
$this->load->view('includes/template');
}
}
and a view like:
<?php echo doctype(); ?>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $pagecontent['seo_title']; ?></title>
<meta name="description" content="<?php echo $pagecontent['seo_description']; ?>" />
<meta name="keywords" content="<?php echo $pagecontent['seo_keywords']; ?>" />
<meta name='robots' content='all' />
<link rel="icon" type="image/ico" href="<?php echo base_url("images/favicon.png"); ?>" />
<?php echo link_tag('css/style.css'); ?>
<script type="text/javascript" language="javascipt" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url("js/jquery.validate.min.js"); ?>"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url("js/main.js"); ?>"></script>
</head>
<body>
<?php $this->load->view('includes/notify'); ?>
<div id="topbar">
<?php $this->load->view('includes/topbar'); ?>
When I try and view the page in my browser I get the following error:
Fatal error: Call to undefined function doctype() in C:\xampp\htdocs\mintfifty\application\modules\site\views\includes\template.php on line 1
The code has worked in all my previous codeigniter (mvc) projects but not (hmvc) why is it not working in HMVC? What am I doing wrong?
This issue is not likely to be caused by HMVC. doctype() function is defined in html helper and it seems that You have not loaded it (Unless you have auto-loaded it). Just load the html helper in your controller and it should work fine.
public function index()
{
$this->load->helper('html');
$this->load->view('includes/template');
}