What I am trying to do is create a grid of data for clients against days. IE, if their backups worked, they get a green square against that day, in a html page.
Is there any CSS or something else that would do the job to check to see if a text document with date and "success" or "fail" is in a directory, then change the background colour of a box in a html file? I'm planning on creating a folder for each client, then having the text files named "20110201Success" or "20110201Failed"
Thanks for any direction you could give me.
You will have to do server-side programming to accomplish this. (PHP, ASP, etc.)
In PHP, use something like:
function getStatus($date)
{
if (file_exists("path/to/file/".$date."Success.txt"))
{
echo "<div class='greenbox'></div>";
}
else
{
echo "<div class='redbox'></div>";
}
}
You need some server-side code to do this.
Related
My Situation
I am currently trying out the new E-Mail function that comes along with the new Zabbix major update 5. In there, you can format your E-Mail with HTML.
I already built something and in that HTML template there is a header like this:
<h3 align="center"><font color="white">Severity: {TRIGGER.SEVERITY}</font></h3>
{TRIGGER.SEVERITY} is a Zabbix Macro that shows the severity of the alert send via Mail.
What I'd love to see is the color of this macro change based on the Severity level. So, if the mail gets send out while "Information" is staying there, i want it to be f.e. green, while when "Disaster" is in there, i want it to be red.
My Question
Is this possible? And if yes, how will I able to achieve this?
Thanks in advance for every comment!
Greetings,
Josh
You can use CSS and assign a CSS class using {TRIGGER.SEVERITY}. Then define the CSS class with your desired colour, e.g. a template could look like this:
<style type="text/css">
.sev_Disaster {
color: #E45959;
}
.sev_High {
color: #E97659;
}
.sev_...
</style>
<h3 align="center"><span class="sev_{TRIGGER.SEVERITY}">Severity: {TRIGGER.SEVERITY}</span></h3>
Notice the class="sev_{TRIGGER.SEVERITY}" which will turn into e.g. class="sev_High" which is defined in the <style> block above.
Another way would be to use different Media types (same transport but different templates) for each severity - this would give you much more freedom but you'd have 6 mostly similar templates and thus changes would've to be implemented in all 6 of them.
i'm searched about this question but all i found was about wordpress not for php or html, my website is based on bootstrap and i want to show a div for onl registered users and give them a message like you must login to view or something like that, is there any way to do that? i can't find topics about it.
i've tried this one:
if (is_user_logged_in()) {
// logged in content
} else {
// not logged in content
}
but it seems to work only on wordpress, i can't find the php or htm version.
You cant write logical code in HTML only you have to embed script or logical language with it, its a markup language only. You can achieve it with php as you said but syntax should be like this for if else statement
<?php
if ( $a > $b ) {
echo "a is greater than b" ;
} else {
echo "a is NOT greater than b" ;
}
?>
You should check in your condition if there is logged in user in session or not.
Tumblr is really impressive in the sense that it allows users to customize their profiles and such. You're allowed to edit the HTML and CSS of your profile.
This is something I want to apply to my own site. However, I'm sure that this will be a big burden on security.
Does anyone have any tips or precautions for a feature like Tumblr's? Also, is it advisable to store the editable HTML and CSS in a database? Thank you :D
P.S.
What about server-side scripting? Lets say I wanted to grant the option of allowing the user to script a button that does something to the database. Any thoughts on how to do this?
This is a very difficult thing to get right, in my experience, if you want users to be able to use absolutely all of HTML/CSS. What you could do, however, is strip all CSS and HTML attributes, and only put "safe" code on a whitelist.
Examples
<p>This is legal code.</p>
<p><a onload="alert('XSS!')">The attribute should be filtered out</a></p>
<p>This is a legal link.
Of course you should still sanitize the href attribute!</p>
<h1>This is bad, because the rest of the page is going to huge,
so make sure there's a closing tag
<style>
.blue {
color: #00f; // keep this (by whitelist)
strange-css-rule: possibly-dangerous; // Filter this out!
}
</style>
Those are just some of the pitfalls you can encounter, though.
I'm not familiar with Tumblr, but I'm pretty sure they're doing something similar to this.
As for the database question, of course you can store HTML and CSS in a database, many systems do this. In your case, you would just need one representation anyway, anything else would just confuse the user ("Why is my CSS rule not applied; it's right there in the code!")
If you are using php then, for database issue you can use mini API system. For example, you want user to allow comment on something and save it in your database, then you can use API like this.
First, api.php file, (URL Location: http://yoursite.com/api.php)
<?php
// ID and Key can be different for all users.
// id = 1234
// key = 'secret_key'
// function = name of the function, user can call
// option = parameter passed to the function
// Now check if id, key, function and option are requested and then
// call function if it exists.
if(isset($_GET['id'], $_GET['key'], $_GET['function'], $_GET['option']) {
$id = $_GET['id'];
$key = $_GET['key'];
if($id == '1234' && $key == 'secret_key') {
// define all functions here
function make_comment($option) {
...code for saving comment to database...
}
if(function_exists($_GET['function'])) {
$_GET['function']($_GET['option']);
}
}
}
?>
Then uesr can call this function from any button using simple call to the API, like
<a href='http://yoursite.com/api.php?id=1234&key=secret_key&function=make_comment&option=i_am_comment'></a>
For the love of everything holy, can someone please help me do this?
I have literally been searching for two hours on how to put a page break in a JEditorPane for when it prints to no avail. I've tried everything from HTML styles to even trying sketchy APIs I've found on random websites.
The code I wrote uses a textPaneEditor to print the data, and I use the HTML styling to format it in the way that I need it to look. So, I need a way to add a page break after I push in all of the data for the next line possibly with the HTML styling. Unfortunately, " " doesn't seem to work.
Here's what my code essentially looks like:
String report = "<font size=\"3\">";
report += "<b> TEST! </b><br>";
report += "PAGE BREAK WOULD GO HERE<br>";
report += "</font>";
JEditorPane textArea = new JEditorPane("text/html", report);
try{
textArea.print(new MessageFormat(""), new MessageFormat(""), true, null, null, true);
}catch(PrinterException e){
e.printStackTrace();
}
TLDR; how do I page break a JTextEditorPane with HTML styling during printing to a printer?
I'm working on solving the same problem myself right now. One thought I've had is to issue two print commands, one for each page to print. Not sure if this is or will be the most elegant or efficient solution but it's something to look into.
I am making a application form for a survey of sorts, and want to include a progress bar at the top showing graphically (not really high end) how far the user has got.
I've spent a while surfing the net and asking Google in various ways to do this but it all comes out with progress bar for upload/download.
I am writing the form in XHTML and CSS with a PHP handler to a MySQL Database. The general thinking seems to be ASP (a few are JQuery)to which I have no experience, if it needs to be ASP then fine, but is there any other way and if it does need to be ASP can you please help?
Thank you in advance.
Possible solutions:
Include another image on each page, showing the progress.
Use php to get the current progress and include the image.
Make a div as a progressbar with different width
...
You could even just use simple html... However, here are two possible solutions with php:
<?php
$progress = 1;
$max = 5
echo "<img src=\"progress_".$progress.".jpg\" />"
?>
where progress_1.jpg, progress_2.jpg,... are your images.
Without images - just CSS:
<?php
$progress = 70;
$max = 100;
?>
<div style="height:15px; width:<?=$max?>px; background-color:silver; padding:1px;">
<div style="height: 100%; width:<?=$progress?>px; background-color:yellow"></div>
</div>