htmlspecialchars
(PHP 4, PHP 5, PHP 7)
htmlspecialchars — Convert special characters to HTML entities
说明
string htmlspecialchars ( string $string [, int $flags = ENT_COMPAT |
ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool
$double_encode = true ]]] )
Certain characters have special significance in HTML, and should be represented
by HTML entities if they are to preserve their meanings. This function returns
a string with these conversions made. If you require all input substrings that
have associated named entities to be translated, use htmlentities() instead.
If the input string passed to this function and the final document share the
same character set, this function is sufficient to prepare input for inclusion
in most contexts of an HTML document. If, however, the input can represent
characters that are not coded in the final document character set and you wish
to retain those characters (as numeric or named entities), both this function
and htmlentities() (which only encodes substrings that have named entity
equivalents) may be insufficient. You may have to use mb_encode_numericentity()
instead.
Performed translations
Character Replacement
& &
(ampersand)
" (double " when ENT_NOQUOTES
quote)
' (single ' (for ENT_HTML401) or ' (for ENT_XML1, ENT_XHTML or
quote) ENT_HTML5), but only when ENT_QUOTES is set
< (less <
than)
> (greater >
than)
参数
string
The string being converted.
flags
A bitmask of one or more of the following flags, which specify how to
handle quotes, invalid code unit sequences and the used document type. The
default is ENT_COMPAT | ENT_HTML401.
Available flags constants
Constant Name Description
ENT_COMPAT Will convert double-quotes and leave single-quotes alone.
ENT_QUOTES Will convert both double and single quotes.
ENT_NOQUOTES Will leave both double and single quotes unconverted.
Silently discard invalid code unit sequences instead of
ENT_IGNORE returning an empty string. Using this flag is discouraged as
it » may have security implications.
Replace invalid code unit sequences with a Unicode
ENT_SUBSTITUTE Replacement Character U+FFFD (UTF-8) or FFFD; (otherwise)
instead of returning an empty string.
Replace invalid code points for the given document type with
a Unicode Replacement Character U+FFFD (UTF-8) or FFFD;
ENT_DISALLOWED (otherwise) instead of leaving them as is. This may be
useful, for instance, to ensure the well-formedness of XML
documents with embedded external content.
ENT_HTML401 Handle code as HTML 4.01.
ENT_XML1 Handle code as XML 1.
ENT_XHTML Handle code as XHTML.
ENT_HTML5 Handle code as HTML 5.
encoding
An optional argument defining the encoding used when converting characters.
If omitted, the default value of the encoding varies depending on the PHP
version in use. In PHP 5.6 and later, the default_charset configuration
option is used as the default value. PHP 5.4 and 5.5 will use UTF-8 as the
default. Earlier versions of PHP use ISO-8859-1.
Although this argument is technically optional, you are highly encouraged
to specify the correct value for your code if you are using PHP 5.5 or
earlier, or if your default_charset configuration option may be set
incorrectly for the given input.
For the purposes of this function, the encodings ISO-8859-1, ISO-8859-15,
UTF-8, cp866, cp1251, cp1252, and KOI8-R are effectively equivalent,
provided the string itself is valid for the encoding, as the characters
affected by htmlspecialchars() occupy the same positions in all of these
encodings.
支持以下字符集：
支持的字符集列表
字符集 别名 描述
ISO-8859-1 ISO8859-1 西欧，Latin-1
ISO-8859-5 ISO8859-5 Little used cyrillic charset (Latin/Cyrillic).
ISO-8859-15 ISO8859-15 西欧，Latin-9。增加欧元符号，法语和芬兰语字母在
Latin-1(ISO-8859-1) 中缺失。
UTF-8 ASCII 兼容的多字节 8 位 Unicode。
cp866 ibm866, 866 DOS 特有的西里尔编码。本字符集在 4.3.2 版本中得到
支持。
Windows-1251, Windows 特有的西里尔编码。本字符集在 4.3.2 版本中
cp1251 win-1251, 得到支持。
1251
cp1252 Windows-1252, Windows 特有的西欧编码。
1252
KOI8-R koi8-ru, 俄语。本字符集在 4.3.2 版本中得到支持。
koi8r
BIG5 950 繁体中文，主要用于中国台湾省。
GB2312 936 简体中文，中国国家标准字符集。
BIG5-HKSCS 繁体中文，附带香港扩展的 Big5 字符集。
Shift_JIS SJIS, 932 日语
EUC-JP EUCJP 日语
MacRoman Mac OS 使用的字符串。
An empty string activates detection from script
'' encoding (Zend multibyte), default_charset and
current locale (see nl_langinfo() and setlocale()
), in this order. Not recommended.
Note: 其他字符集没有认可。将会使用默认编码并抛出异常。
double_encode
When double_encode is turned off PHP will not encode existing html
entities, the default is to convert everything.
返回值
The converted string.
If the input string contains an invalid code unit sequence within the given
encoding an empty string will be returned, unless either the ENT_IGNORE or
ENT_SUBSTITUTE flags are set.
更新日志
版本 说明
5.6.0 The default value for the encoding parameter was changed to be the value
of the default_charset configuration option.
5.4.0 The default value for the encoding parameter was changed to UTF-8.
5.4.0 The constants ENT_SUBSTITUTE, ENT_DISALLOWED, ENT_HTML401, ENT_XML1,
ENT_XHTML and ENT_HTML5 were added.
5.3.0 The constant ENT_IGNORE was added.
5.2.3 The double_encode parameter was added.
范例
Example #1 htmlspecialchars() example
Test", ENT_QUOTES);
echo $new; // Test
?>
注释
Note:
Note that this function does not translate anything beyond what is listed
above. For full entity translation, see htmlentities().
参见
• get_html_translation_table() - 返回使用 htmlspecialchars 和 htmlentities 后
的转换表
• htmlspecialchars_decode() - 将特殊的 HTML 实体转换回普通字符
• strip_tags() - 从字符串中去除 HTML 和 PHP 标记
• htmlentities() - Convert all applicable characters to HTML entities
• nl2br() - 在字符串所有新行之前插入 HTML 换行标记
User Contributed Notes 45 notes
===============================================================================
As of PHP 5.4 they changed default encoding from "ISO-8859-1" to "UTF-8". So if
you get null from htmlspecialchars or htmlentities
where you have only set
you can fix it by
On linux you can find the scripts you need to fix by
grep -Rl "htmlspecialchars\\|htmlentities" /path/to/php/scripts/
===============================================================================
Unfortunately, as far as I can tell, the PHP devs did not provide ANY way to
set the default encoding used by htmlspecialchars() or htmlentities(), even
though they changed the default encoding in PHP 5.4 (*golf clap for PHP devs*).
To save someone the time of trying it, this does not work:
Unfortunately, the only way to not have to explicitly provide the second and
third parameter every single time this function is called (which gets extremely
tedious) is to write your own function as a wrapper:
You can do the same for htmlentities()
===============================================================================
Just a few notes on how one can use htmlspecialchars() and htmlentities() to
filter user input on forms for later display and/or database storage...
1. Use htmlspecialchars() to filter text input values for html input tags.
i.e.,
echo '';
2. Use htmlentities() to filter the same data values for most other kinds of
html tags, i.e.,
echo '
'.htmlentities($data).'
';
3. Use your database escape string function to filter the data for database
updates & insertions, for instance, using postgresql,
pg_query($connection,"UPDATE datatable SET datavalue='".pg_escape_string
($data)."'");
This strategy seems to work well and consistently, without restricting anything
the user might like to type and display, while still providing a good deal of
protection against a wide variety of html and database escape sequence
injections, which might otherwise be introduced through deliberate and/or
accidental input of such character sequences by users submitting their input
data via html forms.
===============================================================================
Problem
In many PHP legacy products the function htmlspecialchars($string) is used to
convert characters like < and > and quotes a.s.o to HTML-entities. That avoids
the interpretation of HTML Tags and asymmetric quote situations.
Since PHP 5.4 for $string in htmlspecialchars($string) utf8 characters are
expected if no charset is defined explicitly as third parameter in the
function. Legacy products are mostly in Latin1 (alias iso-8859-1) what makes
the functions htmlspecialchars(), htmlentites() and html_entity_decode() to
return empty strings if a special character, e. g. a German Umlaut, is present
in $string:
PHP<5.4
echo htmlspecialchars('Woermann') //Output: Woermann
echo htmlspecialchars('Wörmann') //Output: Wörmann
PHP=5.4
echo htmlspecialchars('Woermann') //Output: Woermann
echo htmlspecialchars('Wörmann') //Output: empty
Three alternative solutions
a) Not runnig legacy products on PHP 5.4
b) Change all find spots in your code from
htmlspecialchars($string) and *** to
htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'ISO-8859-1')
c) Replace all htmlspecialchars() and *** with a new self-made function
*** The same is true for htmlentities() and html_entity_decode();
Solution c
1 Make Search and Replace in the concerned legacy project:
Search for: htmlspecialchars
Replace with: htmlXspecialchars
Search for: htmlentities
Replace with: htmlXentities
Search for: html_entity_decode
Replace with: htmlX_entity_decode
2a Copy and paste the following three functions into an existing already
everywhere included PHP-file in your legacy project. (of course that PHP-file
must be included only once per request, otherwise you will get a Redeclare
Function Fatal Error).
function htmlXspecialchars($string, $ent=ENT_COMPAT, $charset='ISO-8859-1') {
return htmlspecialchars($string, $ent, $charset);
}
function htmlXentities($string, $ent=ENT_COMPAT, $charset='ISO-8859-1') {
return htmlentities($string, $ent, $charset);
}
function htmlX_entity_decode($string, $ent=ENT_COMPAT, $charset='ISO-8859-1') {
return html_entity_decode($string, $ent, $charset);
}
or 2b crate a new PHP-file containing the three functions mentioned above,
let's say, z. B. htmlXfunctions.inc.php and include it on the first line of
every PHP-file in your legacy product like this: require_once
('htmlXfunctions.inc.php').
===============================================================================
Be aware of the encoding of your source files!!!
Some of the suggestions here make reference to workarounds where you hard-code
an encoding.
Wörmann'); // Why isn't this working?
?>
As it turns out, it may actually be your text editor that is to blame.
As of PHP 5.4, htmlspecialchars now defaults to the UTF-8 encoding. That said,
many text editors default to non-UTF encodings like ISO-8859-1 (i.e. Latin-1)
or WIN-1252. If you change the encoding of the file to UTF-8, the code above
will now work (i.e. the ö is encoded differently in UTF-8 and ISO-8859-1, and
you need the UTF-8 version).
Make sure you are editing in UTF-8 Unicode mode! Check your UI or manual for
how to convert files to Unicode. It's also a good idea to figure out where to
look in your UI to see what the current file encoding is.
===============================================================================
also see function "urlencode()", useful for passing text with ampersand and
other special chars through url
(i.e. the text is encoded as if sent from form using GET method)
e.g.
link";
?>
produces
link
and if the link is followed, the $_GET["text"] in foo.php will contain "foo?&
bar!"
===============================================================================
Be careful, the "charset" argument IS case sensitive. This is counter-intuitive
and serves no practical purpose because the HTML spec actually has the
opposite.
===============================================================================
A sample function, if anybody want to turn html entities (and special
characters) back to simple. (eg: "è", "<" etc)
function html2specialchars($str){
$trans_table = array_flip(get_html_translation_table(HTML_ENTITIES));
return strtr($str, $trans_table);
}
===============================================================================
i searched for a while for a script, that could see the difference between an
html tag and just < and > placed in the text,
the reason is that i recieve text from a database,
wich is inserted by an html form, and contains text and html tags,
the text can contain < and >, so does the tags,
with htmlspecialchars you can validate your text to XHTML,
but you'll also change the tags, like to ,
so i needed a script that could see the difference between those two...
but i couldn't find one so i made my own one,
i havent fully tested it, but the parts i tested worked perfect!
just for people that were searching for something like this,
it may looks big, could be done easier, but it works for me, so im happy.
";
$text = preg_replace($tags, $replacement, $text);
$text = preg_replace("/=\"\"/", "=", $text);
return $text;
}
?>
an example:
this is greater > than this
this is the same = as this This is a link Bolditalic etc...";
echo fixtags($string);
?>
will echo:
this is smaller < than this
this is greater > than this
this is the same = as this This is a link Bolditalic etc...
I hope its helpfull!!
===============================================================================
I was recently exploring some code when I saw this being used to make data safe
for "SQL".
This function should not be used to make data SQL safe (although to prevent
phishing it is perfectly good).
Here is an example of how NOT to use this function:
query("SELECT `login` FROM `accounts` WHERE `login` =
'$username'");
?>
(Only other check on $_POST['username'] is to make sure it isn't empty which it
is after trim on a white space only name)
The problem here is that it is left to default which allows single quote marks
which are used in the sql query. Turning on magic quotes might fix it but you
should not rely on magic quotes, in fact you should never use it and fix the
code instead. There are also problems with \ not being escaped. Even if magic
quotes were used there would be the problem of allowing usernames longer than
the limit and having some really weird usernames given they are to be used
outside of html, this just provide a front end for registering to another
system using mysql. Of course using it on the output wouldn;t cause that
problem.
Another way to make something of a fix would be to use ENT_QUOTE or do:
query('SELECT `login` FROM `accounts` WHERE `login` =
"'.$username.'";');
?>
Eitherway none of these solutions are good practice and are not entirely
unflawed. This function should simply never be used in such a fashion.
I hope this will prevent newbies using this function incorrectly (as they
apparently do).
===============================================================================
English:
I'd found THE Final Solution!
it finds and replaces all unknown letters!
(like Ä, Ö, Ü, ß, and much much more)
it turn em in a HTML AND XML compatible format
parameter: $text: a String with unsuported letters in it
return: a String where all unsupported(XML und HTML) letters are changed into
the Unicode value (for example Ä)
Deutsch/German:
Ich hab die perfekte Lösung gefunden!
Es findet und tauscht alle unbekannten Buchstaben!
(wie Ä, Ö, Ü, ß, und viel viel mehr)
es tauscht sie in ein HTML und XML kompatibles Format
parameter: $text: ein String mit nichtunterstüzten Buchstaben
return: ein String wo alle von XML und HTML ununterstützten Buchstaben ins
Unicode-Format getauscht sind (z.B. Ä)
FUNCTION:
1114111){
$returnvalue.=substr($text, $i, 1);
}else{
$returnvalue.="".$teil.";";
}
}
return $returnvalue;
}
?>
===============================================================================
If your sending data from one form to another, the data in the textareas and
text inputs may need to have htmlspecialchars("form data", ENT_QUOTES) applied,
assuming you will ever have quotes or less-than signs or any of those special
characters. Using htmlspecialchars will make the text show up properly in the
second form. The changes are automatically undone whenever the form data is
submitted. It does seem a little strange, but it works and my headache is now
starting to go away.
AZ
===============================================================================
This may seem obvious, but it caused me some frustration. If you try and use
htmlspecialchars with the $charset argument set and the string you run it on is
not actually the same charset you specify, you get any empty string returned
without any notice/warning/error.
So make sure your charsets are consistent
I had this problem because a Mac user was submitting posts copy/pasted from a
program and it contained weird chars in it.
===============================================================================
This function can be used to escape single quotes only, and not double quotes,
by calling it as follows.
This works because single/double quote escaping actually each have their own
flag.
#define ENT_HTML_QUOTE_NONE 0
#define ENT_HTML_QUOTE_SINGLE 1
#define ENT_HTML_QUOTE_DOUBLE 2
#define ENT_COMPAT ENT_HTML_QUOTE_DOUBLE
#define ENT_QUOTES (ENT_HTML_QUOTE_DOUBLE | ENT_HTML_QUOTE_SINGLE)
#define ENT_NOQUOTES ENT_HTML_QUOTE_NONE
Snippet from: php-src/ext/standard/html.h
https://github.com/php/php-src/blob/master/ext/standard/html.h
===============================================================================
NOTE:
I made an error in my last post.
The last 3 lines should have read
' .$new. '';
?>
OOPS!
===============================================================================
Another thing important to mention is that
htmlspecialchars(NULL)
returnes an empty string and not NULL!
===============================================================================
> For the purposes of this function, the encodings ISO-8859-1, ISO-8859-15,
UTF-8, cp866, cp1251, cp1252, and KOI8-R are effectively equivalent, provided
the string itself is valid for the encoding, as the characters affected by
htmlspecialchars() occupy the same positions in all of these encodings.
This is not true, actually!
$txt = "Russian text in KOI8-r "; // type here realy russian text in koi8-r
!
htmlspecialchars($txt,null,'KOI8-R') = Russian text in KOI8-r
htmlspecialchars($txt,null,'UTF-8') =
Result is EMPTY !!!
===============================================================================
if your goal is just to protect your page from Cross Site Scripting (XSS)
attack, or just to show HTML tags on a web page (showing on the page,
for example), then using htmlspecialchars() is good enough and better than
using htmlentities(). A minor point is htmlspecialchars() is faster than
htmlentities(). A more important point is, when we use htmlspecialchars($s)
in our code, it is automatically compatible with UTF-8 string. Otherwise, if
we use htmlentities($s), and there happens to be foreign characters in the
string $s in UTF-8 encoding, then htmlentities() is going to mess it up, as it
modifies the byte 0x80 to 0xFF in the string to entities like é.
(unless you specifically provide a second argument and a third argument to
htmlentities(), with the third argument being "UTF-8").
The reason htmlspecialchars($s) already works with UTF-8 string is that, it
changes bytes that are in the range 0x00 to 0x7F to < etc, while leaving
bytes in the range 0x80 to 0xFF unchanged. We may wonder whether
htmlspecialchars() may accidentally change any byte in a 2 to 4 byte UTF-8
character to < etc. The answer is, it won't. When a UTF-8 character is 2
to 4 bytes long, all the bytes in this character is in the 0x80 to 0xFF range.
None can be in the 0x00 to 0x7F range. When a UTF-8 character is 1 byte long,
it is just the same as ASCII, which is 7 bit, from 0x00 to 0x7F. As a result,
when a UTF-8 character is 1 byte long, htmlspecialchars($s) will do its job,
and when the UTF-8 character is 2 to 4 bytes long, htmlspecialchars($s) will
just pass those bytes unchanged. So htmlspecialchars($s) will do the same job
no matter whether $s is in ASCII, ISO-8859-1 (Latin-1), or UTF-8.
===============================================================================
If you seem to have a problem with rendering dynamic RSS files from a database
- try using htmlspecialchars() or htmlentities() on the text you are rendering.
Since XML and RSS is very strict about what is allowed inside nodes, you need
to make sure everything is "A-OK" according to XML standards ...
Especially if the database you're pulling data from is fi.
Use str_replace.
===============================================================================
used this function for making a variable javascript compatible
hope this may help those embedding php in javascripts
===============================================================================
For those having problems after the change of default value of $encoding
argument to UTF-8 since PHP 5.4.
If your old non-UTF8 projects ruined - pls consider:
1. http://php.net/manual/en/function.override-function.php
2. http://php.net/manual/ru/function.runkit-function-redefine.php
The idea - you override the built-in htmlspecialchars() function with your
customized variant which is able to respect non UTF-8 default encoding. This
small piece of code can be then easily inserted somewhere at the start of yout
project. No need to rewrite all htmlspecialchars() entries globally.
I've spent several hours with both approaches. Variant 1 looks good especaially
in combination with http://www.php.net/manual/en/function.rename-function.php
as it allows to call original htmlspecialchars() with just altered default
args. The code could be as follows:
Unfortunatelly this didn't work for me properly - my site managed to call
overriden function but not every time I reloaded the pages. Moreover other PHP
sites crashed under my Apache server as they suddenly started blaming
htmlspecialchars() was not defined. I suppose I had to spend more time to make
it work thread/request/site/whatever-safe.
So I switched to runkit (variant 2). It worked for me, although even after
trying runkit_function_rename()+runkit_function_add() I didn't managed to
recall original htmlspecialchars() function. So as a quick solution I decided
to call htmlentities() instead:
You may be able to implement your more powerfull overriden function.
Good luck!
===============================================================================
I had problems with spanish special characters. So i think in using
htmlspecialchars but my strings also contain HTML.
So I used this :) Hope it help
"), htmlspecialchars
($str, ENT_NOQUOTES, "UTF-8"));
}
?>
===============================================================================
Here is a handy function to htmlalize an array (or scalar) before you hand it
off to xml.
function htmlspecialchars_array($arr = array()) {
$rs = array();
while(list($key,$val) = each($arr)) {
if(is_array($val)) {
$rs[$key] = htmlspecialchars_array($val);
}
else {
$rs[$key] = htmlspecialchars($val, ENT_QUOTES);
}
}
return $rs;
}
===============================================================================
Please note that this function results in an E_WARNING when display_errors is
off and an invalid multibyte string is passed to it (e.g. with 'utf-8' as the
encoding parameter and broken utf-8 characters somewhere in the string).
This is ESPECIALLY IMPORTANT if you have an EXCEPTION-THROWING ERROR HANDLER,
since even though you can't reproduce it in a development mode where
display_errors is on, you MUST wrap your function call in a try-catch, or your
application will crash.
[ The reason PHP makes this distinction is because this is a core function and
many production servers are misconfigured to have display_errors on (to prevent
such things as path disclosure from error messages from accidentally cropping
up). See: http://bugs.php.net/bug.php?id=47494 ]
===============================================================================
The Algo from donwilson at gmail dot com to reverse the action of
htmlspecialchars(), edited for germany:
function unhtmlspecialchars( $string )
{
$string = str_replace ( '&', '&', $string );
$string = str_replace ( ''', '\'', $string );
$string = str_replace ( '"', '"', $string );
$string = str_replace ( '<', '<', $string );
$string = str_replace ( '>', '>', $string );
$string = str_replace ( 'ü', ' ', $string );
$string = str_replace ( 'Ü', ' ', $string );
$string = str_replace ( 'ä', ' ', $string );
$string = str_replace ( 'Ä', ' ', $string );
$string = str_replace ( 'ö', ' ', $string );
$string = str_replace ( 'Ö', ' ', $string );
return $string;
}
===============================================================================
I know some people posted similar functions but may be you are looking for this
version:
function jschars($str)
{
$str = mb_ereg_replace("\\\\", "\\\\", $str);
$str = mb_ereg_replace("\"", "\\\"", $str);
$str = mb_ereg_replace("'", "\\'", $str);
$str = mb_ereg_replace("\r\n", "\\n", $str);
$str = mb_ereg_replace("\r", "\\n", $str);
$str = mb_ereg_replace("\n", "\\n", $str);
$str = mb_ereg_replace("\t", "\\t", $str);
$str = mb_ereg_replace("<", "\\x3C", $str); // for inclusion in HTML
$str = mb_ereg_replace(">", "\\x3E", $str);
return $str;
}
if you use smarty your code may look like:
Test
(Yes, we have the shortcur htmlchars instead of htmlspecialchars, so we are
able to tell the encoding e.g. UTF-8 or ISO-8859-1 to htmlspecialchars)
===============================================================================
a common confusion among beginner is that what is the difference between
htmlentities() and htmlspecialchars() really, because the manual examples are
converting angular brackets for both.
well, htmlentities() will ALSO look for other language characters in the string
e.g German, French or Italian etc. So if you think your attacker can use some
foreign language characters for a XSS attack in URL etc then use htmlentities()
instead of htmlspecialchars().
I hope it helps,
Haroon Ahmad
===============================================================================
If you are using UTF-8 encoding with htmlspecialchars() you may experience
blank values with certain language-specific characters i.e. spanish or
portuguese "âãá".
So instead of using
try
===============================================================================
Here's a simple function I wrote for parsing form data.
It checks if it's an array and it is recursive (it calls itself).
It also decodes things that have already been encoded so it doesn't change &
amp; to &
[In this version,] I found it easier to use a regular expression to check and
see if any previously encoded data exists, then decode it repeatedly until
there is none left, then re-encode it.
$v) {
$out[$key] = formspecialchars($v); // Run
formspecialchars on every element of the array and return the result. Also
maintains the keys.
}
} else {
$out = $var;
while (preg_match($pattern,$out) > 0) {
$out = htmlspecialchars_decode($out,ENT_QUOTES);
}
$out = htmlspecialchars(stripslashes(trim($out)), ENT_QUOTES,
'UTF-8',true); // Trim the variable, strip all slashes, and encode it
}
return $out;
}
?>
===============================================================================
heres a version of the recursive escape function that takes the array byref
rather than byval so saves some resources in case of big arrays
function recurse_array_HTML_safe(&$arr) {
foreach ($arr as $key => $val)
if (is_array($val))
recurse_array_HTML_safe($arr[$key]);
else
$arr[$key] = htmlspecialchars($val, ENT_QUOTES);
}
===============================================================================
Hello,
If you are getting trouble to SGDB write/read HTML data, try to use this:
===============================================================================
This may seem obvious, but if you want to output arbitrary (i.e. user-input)
data as an attribute inside an HTML tag (such as the INPUT tags on a FORM), be
aware of whether you are using ENT_QUOTES or ENT_COMPAT. If you're using
ENT_COMPAT, the attribute must be wrapped in double-quotes, as single-quotes
will not be encoded and the user will be able to inject arbitrary HTML
attributes (including javascript behavior) inside the tag, even though they
will not be able to inject arbitrary HTML tags.
Also, if you want to allow users to input HTML attributes without them being
double-encoded on display, there are two ways to accomplish this:
1 - Run their input through htmlentities_decode() followed by htmlspecialchars
().
2 - Call htmlspecialchars() with $double_encode=false.
There is one functional difference between these two methods: If you want to
perform any search-replace on a user's input (such as word censoring in a
message-board application), the second method will allow users to circumvent it
by HTML-encoding their input, whereas the first will not.
===============================================================================
Actually, if you're using >= 4.0.5, this should theoretically be quicker (less
overhead anyway):
$text = str_replace(array(">", "<", """, "&"), array(">", "<", "
\"", "&"), $text);
===============================================================================
I had a script which detected swearing and wanted to make sure that words such
as 'f ü c k' didn't slip through the system.
After using htmlentities(), the following line converts most extended alphabet
characters back to the standard alphabet so you can spot such problems..
$text=eregi_replace("&([a-z])[a-z0-9]{3,};", "\\\\1", $text);
This changes, for example, 'ü' into 'u' and 'ß' into 's'. Sadly it
also converts '£' and '¶' into 'p' so it's not perfect but does
solve a lot of the problems
===============================================================================
To show result in comment it should be:
Test", ENT_QUOTES);
echo htmlspecialchars($new); // Test
?>
...
===============================================================================
function htmlspecialchars_array($arr = array()) {
$rs = array();
while(list($key,$val) = each($arr)) {
if(is_array($val)) {
$rs[$key] = htmlspecialchars_array($val);
}
else {
$rs[$key] = htmlspecialchars($val, ENT_QUOTES);
}
}
return $rs;
}
===============================================================================
Here are some usefull functions.
They will apply || decode, htmlspecialchars || htmlentities recursivly to
arrays() || to regular $variables. They also protect agains "double encoding".
These functions are an addition to an earlier post. I would like to give the
person some credit but I do not know who it was.
;llnu=u!eJq dHd?>
===============================================================================
The code I posted this morning (for giving back to htmlspecialchars etc. the
old default ISO encoding) had some strange problem, didn't work if a page was
reloaded! Here the code I came up with, without this problem:
")) {
runkit_function_copy('htmlspecialchars', 'htmlspecialchars_new');
runkit_function_redefine(
'htmlspecialchars',
'$string, $flags, $encoding',
'return $encoding == "" ? htmlspecialchars_new($string, ENT_COMPAT |
ENT_HTML401, "ISO-8859-1") : htmlspecialchars_new($string, $flags, $encoding);'
);
runkit_function_copy('htmlentities', 'htmlentities_new');
runkit_function_redefine(
'htmlentities',
'$string, $flags, $encoding',
'return $encoding == "" ? htmlentities_new($string, ENT_COMPAT |
ENT_HTML401, "ISO-8859-1") : htmlentities_new($string, $flags, $encoding);'
);
runkit_function_copy('html_entity_decode', 'html_entity_decode_new');
runkit_function_redefine(
'html_entity_decode',
'$string, $flags, $encoding',
'return $encoding == "" ? html_entity_decode_new($string, ENT_COMPAT |
ENT_HTML401, "ISO-8859-1") : html_entity_decode_new($string, $flags,
$encoding);'
);
}
?>
So first I copy the original function, then I redefine the same.
===============================================================================
I found a simple solution for the changed default character encoding in
htmlspecialchars, htmlentities and html_entity_decode, so my (very) old code
kept running:
")) {
runkit_function_rename('htmlspecialchars', 'htmlspecialchars_new');
runkit_function_add(
'htmlspecialchars',
'$string, $flags, $encoding',
'return $encoding == "" ? htmlspecialchars_new($string, ENT_COMPAT |
ENT_HTML401, "ISO-8859-1") : htmlspecialchars_new($string, $flags, $encoding);'
);
runkit_function_rename('htmlentities', 'htmlentities_new');
runkit_function_add(
'htmlentities',
'$string, $flags, $encoding',
'return $encoding == "" ? htmlentities_new($string, ENT_COMPAT |
ENT_HTML401, "ISO-8859-1") : htmlentities_new($string, $flags, $encoding);'
);
runkit_function_rename('html_entity_decode', 'html_entity_decode_new');
runkit_function_add(
'html_entity_decode',
'$string, $flags, $encoding',
'return $encoding == "" ? html_entity_decode_new($string, ENT_COMPAT |
ENT_HTML401, "ISO-8859-1") : html_entity_decode_new($string, $flags,
$encoding);'
);
}
?>
===============================================================================
In response to the note made by Alexander Nofftz on October 2004, ' is used
instead of ' because IE unfortunately seems to have trouble with the
latter.
===============================================================================
$value) {
$mixed[$key] = htmlspecialchars_deep($value, $quote_style, $charset
);
}
} elseif (is_string($mixed)) {
$mixed = htmlspecialchars(htmlspecialchars_decode($mixed, $quote_style
), $quote_style, $charset);
}
return $mixed;
}
?>
===============================================================================
To html-encode Unicode characters that may not be part of your document
character set (given in the META tag of your page), and so can not be output
directly into your document source, you need to use mb_encode_numericentity().
Pay attention to it's conversion map argument.
===============================================================================
I am not sure, maybe I'm missing something, but I have found something
interesting:
I've been working on a project, where I had to use htmlspecialchars (for
opbvious reasons). I olso needed to de-code the encoded string. What I have
done was almost a copy and paste from php.net:
$trans=get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES);
$trans=array_flip($trans);
$string=strtr($encoded, $trans);
(it looked a bit different in my code, but the idea is clear)
I couldn't get the apostrophe sign de-coded, and I needed it for the tags.
After an hour or so of debuging, I decided do print_r($trans). What I got was:
...
['] => '
...
BUT the apostrophe was encoded to $#039; -> note the zero.
I don't suppose it's a bug, but it definetely IS a potential pitfall, watch out
for this one.
===============================================================================
I am working with xml and zip functions to create an xlsx document from a
template. Just as I thought I had it finished it stopped working. After a bit
of hunting I discovered my zip file began with php notices about undefined
constant. I have no idea why my installation can't remember what ENT_XML1 is,
it used to know it (or so I thought)
To save anyone else this headache I recommend adding the code at the top of
your scripts to verify that these constants are registered. Something like:
defined( "ENT_XML1") or define( "ENT_XML1", 16 );
for each constant you use. Again, I don't know why this problem suddenly came
up, but better safe than "Excel cannot open the file....... format...
extension... corrupted... blah blah blah".
cheers :)
here's a list of the constant values (since they are not on this page) as taken
from html.h for php5
#define ENT_HTML_QUOTE_NONE 0
#define ENT_HTML_QUOTE_SINGLE 1
#define ENT_HTML_QUOTE_DOUBLE 2
#define ENT_HTML_IGNORE_ERRORS 4
#define ENT_HTML_SUBSTITUTE_ERRORS 8
#define ENT_HTML_DOC_TYPE_MASK (16|32)
#define ENT_HTML_DOC_HTML401 0
#define ENT_HTML_DOC_XML1 16
#define ENT_HTML_DOC_XHTML 32
#define ENT_HTML_DOC_HTML5 (16|32)
/* reserve bit 6 */
#define ENT_HTML_SUBSTITUTE_DISALLOWED_CHARS 128
#define ENT_COMPAT ENT_HTML_QUOTE_DOUBLE
#define ENT_QUOTES (ENT_HTML_QUOTE_DOUBLE | ENT_HTML_QUOTE_SINGLE)
#define ENT_NOQUOTES ENT_HTML_QUOTE_NONE
#define ENT_IGNORE ENT_HTML_IGNORE_ERRORS
#define ENT_SUBSTITUTE ENT_HTML_SUBSTITUTE_ERRORS
#define ENT_HTML401 0
#define ENT_XML1 16
#define ENT_XHTML 32
#define ENT_HTML5 (16|32)
#define ENT_DISALLOWED 128


Dressing
2 tbsp sake
1 tbsp miso
1 tbsp soy sauce
1 tbsp mirin
1 tbsp butter
splash of balsamic vinegar
Mizuna, mesclun or watercress
Renkon no Sunomono (lotus root vinegared salad)
I like to prepare this beautiful salad during Oshogatsu, the New Year’s holiday celebration. The lotus is an important symbol in Buddhism, and this dish reminds us to keep on the path to enlightenment.
Wash the renkon well in water, scrubbing with a sponge, removing any brown spots. You should have a creamy white root. If not, peel with a vegetable peeler. Slice into paper thin slices, and soak in boiling water fro 1 minute. This will serve to partially parboil them, yet will retain their crunchy texture.
Combine the remaining ingredients and chill the renkon slices overnight. To serve, garnish with a few thin slices of lemon rind. The photo shows tobiko, which I used for color, but lemon compliments the flavor better. Serve in an attractive communal bowl.
This keeps for up to a week in the refrigerator.


The Tau Beta Pi Engineering Futures Sessions are workshops that provide engineering students training in the soft skills. These non-technical skills are necessary for success in the workplace but rarely included in the engineering curriculum. We offer the Engineering Futures Sessions every semester. The sessions are FREE and open to all engineering students. Please check our calendar for details. For more information, check out the Engineering Futures Page.
The mission of MindSET, the TBP National K-12 Math & Science Program, is to establish and support math and science intervention programs which contribute to enhanced preparation of students in the K-12 system, thus enabling them to qualify for the pursuit of careers in STEM disciplines, preparing them for competitive success in the global marketplace, and equipping them for driving the nation’s economy. We hold a MindSET event every year. For more information, please check our calendar or email our Outreach Chair.
Besides focusing on EFs and MindSET, our Tau Beta Pi chapter also is heavily involved in the community. We try to make the most out of our resources to leverage our platform to make as positive of an affect as we can on society. Our events include but are not limited to the Houston Food Bank, Meals on Wheels, and student mentoring.


Introduction
Regular expressions are used for blacklist items and to verify that your regular expression is working as expected, ToplistX includes an interface
where you can test your regular expressions against specific values. This document provides an overview of that interface.
Accessing the Test Interface
To access the test interface click on the icon in the blacklist interface.
This will popup a window where you will be able to enter the regular expression to test and the value to test it against.
Testing Regular Expressions
In the test interface enter the regular expression to test in the field labeled Regular Expression and the value to test it against in the Test String field. Press the Test
Regex button to test your regular expression. When you press this button, a request will be sent to your server, so allow a few seconds for it to complete. When the test is completed
the results will display in the Results section. The results will show you if the string you entered matched the regular expression, and if so it will show you the part that matched.
In ToplistX the Perl Compatible Regular Expressions format is used for regular expressions. If you are not familiar
with regular expressions, please see the Pattern Syntax portion of the PHP manual for additional
information.
When entering your regular expression, you do not need to use any delimiters at the beginning and end of the regular expression. For example, you could use this value to test if a string
contains an IP address:
\d+\.\d+\.\d+\.\d+
If you then enter "My IP address is <IP_ADDRESS>" and press the button, this will indicate a successful match on "<IP_ADDRESS>".


Class Text
Inheritance
Namespace: VBGraphics
Assembly: VBGraphics.dll
Syntax
public class Text
Methods
| Improve this Doc View SourceDrawText(GraphicsWindow, String, Int32, Int32, Color, Font)
Draw the specified text with the top-left corner at (x, y), using the specified color and font.
Declaration
[Extension]
public static void DrawText(this GraphicsWindow gw, string text, int x, int y, Color color, Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsWindow | gw | The graphics window object |
| String | text | The text to draw |
| Int32 | x | The x-coordinate of the top-left corner of the text |
| Int32 | y | The y-coordinate of the top-left corner of the text |
| Color | color | The color of the text |
| Font | font | The font of the text |
DrawText(GraphicsWindow, String, Int32, Int32, Color, String, Single, FontStyle)
Draw the specified text with the top-left corner at (x, y), using the specified color, and with the font defined by its name, size and style.
Declaration
[Extension]
public static void DrawText(this GraphicsWindow gw, string text, int x, int y, Color color, string fontName, float emSize, FontStyle fontStyle = FontStyle.Regular)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsWindow | gw | The graphics window object |
| String | text | The text to draw |
| Int32 | x | The x-coordinate of the top-left corner of the text |
| Int32 | y | The y-coordinate of the top-left corner of the text |
| Color | color | The color of the text |
| String | fontName | The name of the font |
| Single | emSize | The em-size of the font, in points. 1 point = 4/3 pixels. |
| FontStyle | fontStyle | The font style |
DrawTextInRectangle(GraphicsWindow, String, Int32, Int32, Int32, Int32, Color, Font, TextFormatFlags)
Draw the specified text with a defined bounding rectangle, using the specified color and font. The bounding rectangle is defined by the coordinates of the top-left corner and also its width and height.
Declaration
[Extension]
public static void DrawTextInRectangle(this GraphicsWindow gw, string text, int x, int y, int width, int height, Color color, Font font, TextFormatFlags flags = TextFormatFlags.Default | TextFormatFlags.Left | TextFormatFlags.Top | TextFormatFlags.GlyphOverhangPadding)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsWindow | gw | The graphics window object |
| String | text | The text to draw |
| Int32 | x | The x-coordinate of the top-left corner of the bounding rectangle |
| Int32 | y | The y-coordinate of the top-left corner of the bounding rectangle |
| Int32 | width | The width of the bounding rectangle |
| Int32 | height | The height of the bounding rectangle |
| Color | color | The color of the text |
| Font | font | The font of the text |
| TextFormatFlags | flags | A flag that controls the paragraph formatting of the text |
DrawTextInRectangle(GraphicsWindow, String, Int32, Int32, Int32, Int32, Color, String, Single, FontStyle, TextFormatFlags)
Draw the specified text with a defined bounding rectangle, using the specified color, and with the font defined by its name, size and style. The bounding rectangle is defined by the coordinates of the top-left corner and also its width and height.
Declaration
[Extension]
public static void DrawTextInRectangle(this GraphicsWindow gw, string text, int x, int y, int width, int height, Color color, string fontName, float emSize, FontStyle fontStyle = FontStyle.Regular, TextFormatFlags flags = TextFormatFlags.Default | TextFormatFlags.Left | TextFormatFlags.Top | TextFormatFlags.GlyphOverhangPadding)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsWindow | gw | The graphics window object |
| String | text | The text to draw |
| Int32 | x | The x-coordinate of the top-left corner of the bounding rectangle |
| Int32 | y | The y-coordinate of the top-left corner of the bounding rectangle |
| Int32 | width | The width of the bounding rectangle |
| Int32 | height | The height of the bounding rectangle |
| Color | color | The color of the text |
| String | fontName | The name of the font |
| Single | emSize | The em-size of the font, in points. 1 point = 4/3 pixels. |
| FontStyle | fontStyle | The font style |
| TextFormatFlags | flags | A flag that controls the paragraph formatting of the text |
ReadLine(GraphicsWindow, Int32, Int32, Int32, Color, Color, String, Single, FontStyle, Nullable<Color>, Nullable<Color>, TextFormatFlags)
Display a text box, and ask the user to input a line of text. The text box has its top-left corner at (x, y), with the specified width, background color and foreground color. The text box can optionally change its color after the user has finished inputting.
Declaration
[Extension]
public static string ReadLine(this GraphicsWindow gw, int x, int y, int width, Color foreColor, Color backColor, string fontName, float emSize, FontStyle fontStyle = FontStyle.Regular, Color? foreColorAfterFinish = default (Color? ), Color? backColorAfterFinish = default (Color? ), TextFormatFlags flags = TextFormatFlags.Default | TextFormatFlags.Left | TextFormatFlags.Top | TextFormatFlags.GlyphOverhangPadding)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsWindow | gw | The graphics window object |
| Int32 | x | The x-coordinate of the top-left corner of the text box |
| Int32 | y | The y-coordinate of the top-left corner of the text box |
| Int32 | width | The width of the text box |
| Color | foreColor | The foreground color of the text box |
| Color | backColor | The background color of the text box |
| String | fontName | The name of the font |
| Single | emSize | The em-size of the font, in points. 1 point = 4/3 pixels. |
| FontStyle | fontStyle | The font style |
| System.Nullable<Color> | foreColorAfterFinish | The foreground color of the text box after the user has finished inputting |
| System.Nullable<Color> | backColorAfterFinish | The background color of the text box after the user has finished inputting |
| TextFormatFlags | flags | A flag that controls the paragraph formatting of the text |
Returns
| Type | Description |
|---|---|
| String | The user inputt |


Mirai is an easy level machine based on Linux, the initial approach has no exploits, just default credentials to SSH provided by Raspberry Pi.
The privilege escalation stage requires some knowledge about Linux partitions and how them works after some user actions.
Recon
On port 80, the server has a blank page, after running the gobuster tool for web enumeration we got the following output:
The /admin web directory has an administration dashboard named Pi-hole, a web interface for Raspberry Pi administration:
The Pi-hole default credentials doesn’t work.
Exploiting - Using Raspberry Pi default SSH credentials
Raspberry Pi devices comes with default SSH credentials, pi:raspberry, with that info we can try if the machine has these credentials:
Done, now we have access to the machine as pi user!
Post Exploitation - Dealing with Linux partitions and user file actions
After the system enumeration we noticed in sudo -l output that we’re able to escalate our privileges to root with a simple sudo su:
Now we have root privileges but there’s a trick:
The root.txt flag has the following content:
I lost my original root.txt! I think I may have a backup on my USB stick…
We need to enumerate Linux partitions to find the USB partition:
There’s a USB partition located at /media/usbstick:
In this partition there’s a file named damnit.txt with the following content:
Damnit! Sorry man I accidentally deleted your files off the USB stick. Do you know if there is any way to get them back?
-James
Knowing that James deleted the flag file, we can try to recover it with the following command:


This is a basic clone of the Trello web app which mimics some of the basic functionality. It's still missing some features and hasn't been pushed online at this point.
Ruby on Rails, Backbone.js, CSS, jQuery


FITSIO Home
Next: 6. The CFITSIO Iterator
Up: 5.8 Utility Routines
Previous: 5.8.2 Date and Time
Contents
The following utility routines may be useful for certain applications.
- 1
- Return the revision number of the CFITSIO library.
The revision number will be incremented with each new
release of CFITSIO.
float fits_get_version / ffvers ( > float *version)
- 2
- Write an 80-character message to the CFITSIO error stack. Application
programs should not normally write to the stack, but there may be
some situations where this is desirable.
void fits_write_errmsg / ffpmsg (char *err_msg)
- 3
- Convert a character string to uppercase (operates in place).
void fits_uppercase / ffupch (char *string)
- 4
- Compare the input template string against the reference string
to see if they match. The template string may contain wildcard
characters: '*' will match any sequence of characters (including
zero characters) and '?' will match any single character in the
reference string. The '#' character will match any consecutive string
of decimal digits (0 - 9). If casesen = CASESEN = TRUE then the match will
be case sensitive, otherwise the case of the letters will be ignored
if casesen = CASEINSEN = FALSE. The returned MATCH parameter will be
TRUE if the 2 strings match, and EXACT will be TRUE if the match is
exact (i.e., if no wildcard characters were used in the match).
Both strings must be 68 characters or less in length.
void fits_compare_str / ffcmps
(char *templt, char *string, int casesen, > int *match, int *exact)
- 5
- Split a string containing a list of names (typically file names or column
names) into individual name tokens by a sequence of calls to
fits_split_names. The names in the list must be delimited by a comma
and/or spaces. This routine ignores spaces and commas that occur
within parentheses, brackets, or curly brackets. It also strips any
leading and trailing blanks from the returned name.
This routine is similar to the ANSI C 'strtok' function:
The first call to fits_split_names has a non-null input string.
It finds the first name in the string and terminates it by overwriting
the next character of the string with a null terminator and returns a
pointer to the name. Each subsequent call, indicated by a NULL value
of the input string, returns the next name, searching from just past
the end of the previous name. It returns NULL when no further names
are found.
char *fits_split_names(char *namelist)
The following example shows how a string would be split into 3 names:
myfile[1][bin (x,y)=4], file2.fits file3.fits
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^
1st name 2nd name 3rd name
- 6
- Test that the keyword name contains only legal characters (A-Z,0-9,
hyphen, and underscore) or that the keyword record contains only legal
printable ASCII characters
int fits_test_keyword / fftkey (char *keyname, > int *status)
int fits_test_record / fftrec (char *card, > int *status)
- 7
- Test whether the current header contains any NULL (ASCII 0) characters.
These characters are illegal in the header, but they will go undetected
by most of the CFITSIO keyword header routines, because the null is
interpreted as the normal end-of-string terminator. This routine returns
the position of the first null character in the header, or zero if there
are no nulls. For example a returned value of 110 would indicate that
the first NULL is located in the 30th character of the second keyword
in the header (recall that each header record is 80 characters long).
Note that this is one of the few CFITSIO routines in which the returned
value is not necessarily equal to the status value).
int fits_null_check / ffnchk (char *card, > int *status)
- 8
- Parse a header keyword record and return the name of the keyword,
and the length of the name.
The keyword name normally occupies the first 8 characters of the
record, except under the HIERARCH convention where the name can
be up to 70 characters in length.
int fits_get_keyname / ffgknm
(char *card, > char *keyname, int *keylength, int *status)
- 9
- Parse a header keyword record, returning the value (as
a literal character string) and comment strings. If the keyword has no
value (columns 9-10 not equal to '= '), then a null value string is
returned and the comment string is set equal to column 9 - 80 of the
input string.
int fits_parse_value / ffpsvc
(char *card, > char *value, char *comment, int *status)
- 10
- Construct an array indexed keyword name (ROOT + nnn).
This routine appends the sequence number to the root string to create
a keyword name (e.g., 'NAXIS' + 2 = 'NAXIS2')
int fits_make_keyn / ffkeyn
(char *keyroot, int value, > char *keyname, int *status)
- 11
- Construct a sequence keyword name (n + ROOT).
This routine concatenates the sequence number to the front of the
root string to create a keyword name (e.g., 1 + 'CTYP' = '1CTYP')
int fits_make_nkey / ffnkey
(int value, char *keyroot, > char *keyname, int *status)
- 12
- Determine the data type of a keyword value string. This routine
parses the keyword value string to determine its data type.
Returns 'C', 'L', 'I', 'F' or 'X', for character string, logical,
integer, floating point, or complex, respectively.
int fits_get_keytype / ffdtyp
(char *value, > char *dtype, int *status)
- 13
- Determine the integer data type of an integer keyword value string.
The returned datatype value is the minimum integer datatype (starting
from top of the following list and working down) required
to store the integer value:
Data Type Range
TSBYTE: -128 to 127
TBYTE: 128 to 255
TSHORT: -32768 to 32767
TUSHORT: 32768 to 65535
TINT -2147483648 to<PHONE_NUMBER>
TUINT<PHONE_NUMBER> to<PHONE_NUMBER>
TLONGLONG -9223372036854775808 to<PHONE_NUMBER>854775807
- The *neg parameter returns 1 if the input value is
negative and returns 0 if it is non-negative.
int fits_get_inttype / ffinttyp
(char *value, > int *datatype, int *neg, int *status)
- 14
- Return the class of an input header record. The record is classified
into one of the following categories (the class values are
defined in fitsio.h). Note that this is one of the few CFITSIO
routines that does not return a status value.
Class Value Keywords
TYP_STRUC_KEY 10 SIMPLE, BITPIX, NAXIS, NAXISn, EXTEND, BLOCKED,
GROUPS, PCOUNT, GCOUNT, END
XTENSION, TFIELDS, TTYPEn, TBCOLn, TFORMn, THEAP,
and the first 4 COMMENT keywords in the primary array
that define the FITS format.
TYP_CMPRS_KEY 20 The experimental keywords used in the compressed
image format ZIMAGE, ZCMPTYPE, ZNAMEn, ZVALn,
ZTILEn, ZBITPIX, ZNAXISn, ZSCALE, ZZERO, ZBLANK
TYP_SCAL_KEY 30 BSCALE, BZERO, TSCALn, TZEROn
TYP_NULL_KEY 40 BLANK, TNULLn
TYP_DIM_KEY 50 TDIMn
TYP_RANG_KEY 60 TLMINn, TLMAXn, TDMINn, TDMAXn, DATAMIN, DATAMAX
TYP_UNIT_KEY 70 BUNIT, TUNITn
TYP_DISP_KEY 80 TDISPn
TYP_HDUID_KEY 90 EXTNAME, EXTVER, EXTLEVEL, HDUNAME, HDUVER, HDULEVEL
TYP_CKSUM_KEY 100 CHECKSUM, DATASUM
TYP_WCS_KEY 110 WCS keywords defined in the the WCS papers, including:
CTYPEn, CUNITn, CRVALn, CRPIXn, CROTAn, CDELTn
CDj_is, PVj_ms, LONPOLEs, LATPOLEs
TCTYPn, TCTYns, TCUNIn, TCUNns, TCRVLn, TCRVns, TCRPXn,
TCRPks, TCDn_k, TCn_ks, TPVn_m, TPn_ms, TCDLTn, TCROTn
jCTYPn, jCTYns, jCUNIn, jCUNns, jCRVLn, jCRVns, iCRPXn,
iCRPns, jiCDn, jiCDns, jPVn_m, jPn_ms, jCDLTn, jCROTn
(i,j,m,n are integers, s is any letter)
TYP_REFSYS_KEY 120 EQUINOXs, EPOCH, MJD-OBSs, RADECSYS, RADESYSs, DATE-OBS
TYP_COMM_KEY 130 COMMENT, HISTORY, (blank keyword)
TYP_CONT_KEY 140 CONTINUE
TYP_USER_KEY 150 all other keywords
int fits_get_keyclass / ffgkcl (char *card)
- 15
- Parse the 'TFORM' binary table column format string.
This routine parses the input TFORM character string and returns the
integer data type code, the repeat count of the field, and, in the case
of character string fields, the length of the unit string. See Appendix
B for the allowed values for the returned typecode parameter. A
null pointer may be given for any output parameters that are not needed.
int fits_binary_tform / ffbnfm
(char *tform, > int *typecode, long *repeat, long *width,
int *status)
int fits_binary_tformll / ffbnfmll
(char *tform, > int *typecode, LONGLONG *repeat, long *width,
int *status)
- 16
- Parse the 'TFORM' keyword value that defines the column format in
an ASCII table. This routine parses the input TFORM character
string and returns the data type code, the width of the column,
and (if it is a floating point column) the number of decimal places
to the right of the decimal point. The returned data type codes are
the same as for the binary table, with the following
additional rules: integer columns that are between 1 and 4 characters
wide are defined to be short integers (code = TSHORT). Wider integer
columns are defined to be regular integers (code = TLONG). Similarly,
Fixed decimal point columns (with TFORM = 'Fw.d') are defined to
be single precision reals (code = TFLOAT) if w is between 1 and 7 characters
wide, inclusive. Wider 'F' columns will return a double precision
data code (= TDOUBLE). 'Ew.d' format columns will have datacode = TFLOAT,
and 'Dw.d' format columns will have datacode = TDOUBLE. A null
pointer may be given for any output parameters that are not needed.
int fits_ascii_tform / ffasfm
(char *tform, > int *typecode, long *width, int *decimals,
int *status)
- 17
- Calculate the starting column positions and total ASCII table width
based on the input array of ASCII table TFORM values. The SPACE input
parameter defines how many blank spaces to leave between each column
(it is recommended to have one space between columns for better human
readability).
int fits_get_tbcol / ffgabc
(int tfields, char **tform, int space, > long *rowlen,
long *tbcol, int *status)
- 18
- Parse a template header record and return a formatted 80-character string
suitable for appending to (or deleting from) a FITS header file.
This routine is useful for parsing lines from an ASCII template file
and reformatting them into legal FITS header records. The formatted
string may then be passed to the fits_write_record, ffmcrd, or
fits_delete_key routines
to append or modify a FITS header record.
int fits_parse_template / ffgthd
(char *templt, > char *card, int *keytype, int *status)
The input templt character string generally should contain 3 tokens:
(1) the KEYNAME, (2) the VALUE, and (3) the COMMENT string. The
TEMPLATE string must adhere to the following format:
- -
- The KEYNAME token must begin in columns 1-8 and be a maximum of 8
characters long. A legal FITS keyword name may only
contain the characters A-Z, 0-9, and '-' (minus sign) and
underscore. This routine will automatically convert any lowercase
characters to uppercase in the output string. If the first 8 characters
of the template line are
blank then the remainder of the line is considered to be a FITS comment
(with a blank keyword name).
- -
- The VALUE token must be separated from the KEYNAME token by one or more
spaces and/or an '=' character. The data type of the VALUE token
(numeric, logical, or character string) is automatically determined
and the output CARD string is formatted accordingly. The value
token may be forced to be interpreted as a string (e.g. if it is a
string of numeric digits) by enclosing it in single quotes.
If the value token is a character string that contains 1 or more
embedded blank space characters or slash ('/') characters then the
entire character string must be enclosed in single quotes.
- -
- The COMMENT token is optional, but if present must be separated from
the VALUE token by a blank space or a '/' character.
- -
- One exception to the above rules is that if the first non-blank
character in the first 8 characters of the template string is a
minus sign ('-') followed
by a single token, or a single token followed by an equal sign,
then it is interpreted as the name of a keyword which is to be
deleted from the FITS header.
- -
- The second exception is that if the template string starts with
a minus sign and is followed by 2 tokens (without an equals sign between
them) then the second token
is interpreted as the new name for the keyword specified by
first token. In this case the old keyword name (first token)
is returned in characters 1-8 of the returned CARD string, and
the new keyword name (the second token) is returned in characters
41-48 of the returned CARD string. These old and new names
may then be passed to the ffmnam routine which will change
the keyword name.
The keytype output parameter indicates how the returned CARD string
should be interpreted:
keytype interpretation
------- -------------------------------------------------
-2 Rename the keyword with name = the first 8 characters of CARD
to the new name given in characters 41 - 48 of CARD.
-1 delete the keyword with this name from the FITS header.
0 append the CARD string to the FITS header if the
keyword does not already exist, otherwise update
the keyword value and/or comment field if is already exists.
1 This is a HISTORY or COMMENT keyword; append it to the header
2 END record; do not explicitly write it to the FITS file.
EXAMPLES: The following lines illustrate valid input template strings:
INTVAL 7 / This is an integer keyword
RVAL 34.6 / This is a floating point keyword
EVAL=-12.45E-03 / This is a floating point keyword in exponential notation
lval F / This is a boolean keyword
This is a comment keyword with a blank keyword name
SVAL1 = 'Hello world' / this is a string keyword
SVAL2 '123.5' this is also a string keyword
sval3 123+ / this is also a string keyword with the value '123+ '
# the following template line deletes the DATE keyword
- DATE
# the following template line modifies the NAME keyword to OBJECT
- NAME OBJECT
- 19
- Translate a keyword name into a new name, based on a set of patterns.
This routine is useful for translating keywords in cases such as
adding or deleting columns in
a table, or copying a column from one table to another, or extracting
an array from a cell in a binary table column into an image extension. In
these cases, it is necessary to translate the names of the keywords associated
with the original table column(s) into the appropriate keyword name in the final
file. For example, if column 2 is deleted from a table,
then the value of 'n' in all the
TFORMn and TTYPEn keywords for columns 3 and higher must be decremented
by 1. Even more complex translations are sometimes needed to convert the
WCS keywords when extracting an image out of a table column cell into
a separate image extension.
The user passes an array of patterns to be matched. Input pattern
number i is pattern[i][0], and output pattern number i is
pattern[i][1]. Keywords are matched against the input patterns. If a
match is found then the keyword is re-written according to the output
pattern.
Order is important. The first match is accepted. The fastest match
will be made when templates with the same first character are grouped
together.
Several characters have special meanings:
i,j - single digits, preserved in output template
n - column number of one or more digits, preserved in output template
m - generic number of one or more digits, preserved in output template
a - coordinate designator, preserved in output template
# - number of one or more digits
? - any character
* - only allowed in first character position, to match all
keywords; only useful as last pattern in the list
i, j, n, and m are returned by the routine.
For example, the input pattern "iCTYPn" will match "1CTYP5" (if n_value
is 5); the output pattern "CTYPEi" will be re-written as "CTYPE1".
Notice that "i" is preserved.
The following output patterns are special:
"-" - do not copy a keyword that matches the corresponding input pattern
"+" - copy the input unchanged
The inrec string could be just the 8-char keyword name, or the entire
80-char header record. Characters 9 - 80 in the input string simply get
appended to the translated keyword name.
If n_range = 0, then only keywords with 'n' equal to n_value will be
considered as a pattern match. If n_range = +1, then all values of
'n' greater than or equal to n_value will be a match, and if -1,
then values of 'n' less than or equal to n_value will match.
int fits_translate_keyword(
char *inrec, /* I - input string */
char *outrec, /* O - output converted string, or */
/* a null string if input does not */
/* match any of the patterns */
char *patterns[][2],/* I - pointer to input / output string */
/* templates */
int npat, /* I - number of templates passed */
int n_value, /* I - base 'n' template value of interest */
int n_offset, /* I - offset to be applied to the 'n' */
/* value in the output string */
int n_range, /* I - controls range of 'n' template */
/* values of interest (-1,0, or +1) */
int *pat_num, /* O - matched pattern number (0 based) or -1 */
int *i, /* O - value of i, if any, else 0 */
int *j, /* O - value of j, if any, else 0 */
int *m, /* O - value of m, if any, else 0 */
int *n, /* O - value of n, if any, else 0 */
int *status) /* IO - error status */
- Here is an example of some of the patterns used to convert the keywords associated
with an image in a cell of a table column into the keywords appropriate for
an IMAGE extension:
char *patterns[][2] = {{"TSCALn", "BSCALE" }, /* Standard FITS keywords */
{"TZEROn", "BZERO" },
{"TUNITn", "BUNIT" },
{"TNULLn", "BLANK" },
{"TDMINn", "DATAMIN" },
{"TDMAXn", "DATAMAX" },
{"iCTYPn", "CTYPEi" }, /* Coordinate labels */
{"iCTYna", "CTYPEia" },
{"iCUNIn", "CUNITi" }, /* Coordinate units */
{"iCUNna", "CUNITia" },
{"iCRVLn", "CRVALi" }, /* WCS keywords */
{"iCRVna", "CRVALia" },
{"iCDLTn", "CDELTi" },
{"iCDEna", "CDELTia" },
{"iCRPXn", "CRPIXi" },
{"iCRPna", "CRPIXia" },
{"ijPCna", "PCi_ja" },
{"ijCDna", "CDi_ja" },
{"iVn_ma", "PVi_ma" },
{"iSn_ma", "PSi_ma" },
{"iCRDna", "CRDERia" },
{"iCSYna", "CSYERia" },
{"iCROTn", "CROTAi" },
{"WCAXna", "WCSAXESa"},
{"WCSNna", "WCSNAMEa"}};
- 20
- Translate the keywords in the input HDU into the keywords that are
appropriate for the output HDU. This is a driver routine that calls
the previously described routine.
int fits_translate_keywords(
fitsfile *infptr, /* I - pointer to input HDU */
fitsfile *outfptr, /* I - pointer to output HDU */
int firstkey, /* I - first HDU record number to start with */
char *patterns[][2],/* I - pointer to input / output keyword templates */
int npat, /* I - number of templates passed */
int n_value, /* I - base 'n' template value of interest */
int n_offset, /* I - offset to be applied to the 'n' */
/* value in the output string */
int n_range, /* I - controls range of 'n' template */
/* values of interest (-1,0, or +1) */
int *status) /* IO - error status */
- 21
- Parse the input string containing a list of rows or row ranges, and
return integer arrays containing the first and last row in each
range. For example, if rowlist = "3-5, 6, 8-9" then it will
return numranges = 3, rangemin = 3, 6, 8 and rangemax = 5, 6, 9.
At most, 'maxranges' number of ranges will be returned. 'maxrows'
is the maximum number of rows in the table; any rows or ranges
larger than this will be ignored. The rows must be specified in
increasing order, and the ranges must not overlap. A minus sign
may be use to specify all the rows to the upper or lower bound, so
"50-" means all the rows from 50 to the end of the table, and "-"
means all the rows in the table, from 1 - maxrows.
int fits_parse_range / ffrwrg(char *rowlist, LONGLONG maxrows, int maxranges, >
int *numranges, long *rangemin, long *rangemax, int *status)
int fits_parse_rangell / ffrwrgll(char *rowlist, LONGLONG maxrows, int maxranges, >
int *numranges, LONGLONG *rangemin, LONGLONG *rangemax, int *status)
- 22
- Check that the Header fill bytes (if any) are all blank. These are the bytes
that may follow END keyword and before the beginning of data unit,
or the end of the HDU if there is no data unit.
int ffchfl(fitsfile *fptr, > int *status)
- 23
- Check that the Data fill bytes (if any) are all zero (for IMAGE or
BINARY Table HDU) or all blanks (for ASCII table HDU). These file
bytes may be located after the last valid data byte in the HDU and
before the physical end of the HDU.
int ffcdfl(fitsfile *fptr, > int *status)
- 24
- Estimate the root-mean-squared (RMS) noise in an image.
These routines are mainly for use with the Hcompress image compression
algorithm. They return an estimate of the RMS noise in the background
pixels of the image. This robust algorithm (written by Richard
White, STScI) first attempts to estimate the RMS value
as 1.68 times the median of the absolute differences between successive
pixels in the image. If the median = 0, then the
algorithm falls back to computing the RMS of the difference between successive
pixels, after several N-sigma rejection cycles to remove
extreme values. The input parameters are: the array of image pixel values
(either float or short values), the number of values in the array,
the value that is used to represent null pixels (enter a very
large number if there are no null pixels).
int fits_rms_float (float fdata[], int npix, float in_null_value,
> double *rms, int *status)
int fits_rms_short (short fdata[], int npix, short in_null_value,
> double *rms, int *status)
- 25
- Was CFITSIO compiled with the -D_REENTRANT directive
so that it may be safely used in multi-threaded environments?
The following function returns 1 if yes, 0 if no. Note, however,
that even if the -D_REENTRANT directive was specified, this does
not guarantee that the CFITSIO routines are thread-safe, because
some compilers may not support this feature.
int fits_is_reentrant(void)
FITSIO Home
Next: 6. The CFITSIO Iterator
Up: 5.8 Utility Routines
Previous: 5.8.2 Date and Time
Contents


| GMT | Event | vol | actual | cons | previous |
|---|---|---|---|---|---|
| Monday, Apr 25 | |||||
| 08:00 |
|
106.6 | 107.0 | 106.7 Revised from 102.3 | |
| 10:00 |
|
-11 | -15 | -14 | |
| 14:00 |
|
1% | 2% | ||
| 08:00 |
|
106.6 | 107.0 | 106.7 Revised from 102.3 |


tial-scale=1.0">
You can have multiple galleries on a single page, captions are optional. Works best with webkit browsers - non-webkit browsers not so best.
This code is free to use with no restrictions. https://github.com/tysonhummel/simple-photo-gallery
Click a thumbnail below to open the viewer.
Basic example using the same large image for both the thumbnails and the viewer.
To use smaller images for thumbnails, just add "-thumb" to your thumbnail image file names. Example: "image-thumb.jpg", then use that image on the main page. To use captions, add it like this <img src="path/to/image-thumb.jpg" data-caption="Caption goes here" />.


Google Fi brings spam warnings and Wi-Fi calling to more phones
by Alex ZhengNo matter what phone you use with Google Fi, our phone plan in the U.S., you’ll get great features—like reliable coverage, easy group plans and high speed international data coverage for the same rates you pay at home.
We’ve been working to bring the Google Fi experience to more people across the U.S., and last year we expanded Fi plans to the majority of Android devices and iPhones. Today, we’re bringing some favorite Fi features to these devices.
Spam call warnings and the ability to block specific numbers are now available on all phones compatible with Fi—including iPhone—so you don’t have to worry about unwanted calls.
Plus, we are extending our enhanced VPN network and WiFi calling to all Android phones on Fi. When you use our enhanced VPN network, all of your cellular and WiFi traffic are encrypted so you have peace of mind, knowing nobody else can see your online activity. And with WiFi calling, you can make and receive calls as long as you have a WiFi connection, even when you don’t have cellular coverage.
To use these features, download the Google Fi app and then look for Phone Settings in the app.


In the first blog entry, “NGinx Notes from URL Redirect Project on Google Cloud with Terraform & Packer - Part 1” I covered getting a basic Nginx URL Redirector setup and running. Now it’s time to dig into some of the next steps.
Since we have an operative server running that we want to automate, I’ll actually just wipe out the server we built in the first part of this series. Albeit I will refer back to it when I get to the process of recreating this server with Packer and Terraform. So first things first, let’s actually setup the networking elements needed to put the server into action.
Infrastructure : The first Terraform Resources
The first thing I need is an IP and an A Record in DNS to map to the server that’ll be in charge of the redirection. With Terraform, I can automate this, and for a quick review of how to get started with Google Cloud and Terraform, check out my post “Working With Google Compute Engine (GCE) using Terraform (With a load of Bash Scripts too)“. With that, I’ll add the following files to this project including the following Terraform resources. The way I do this is simply create a directory and run git init
to make that a repo, then just push it up to Github or wherever the remote needs to be stored. I’ll work based on that from here on out with this series.
- Filename:
connections.tf
This file will simply host the connection for the provider I’ll be building the infrastructure resources against. In this case, I’ll be working against Google Cloud. The credentials
section in the file has the interpolated local file account.json
that I have my secret key in. It’s one of the multiple ways you can setup your Google Cloud key to use with Packer, Terraform, or other tools. For more information or for specific directions on getting an account.json file just read my previous post on using Google Cloud & Terraform.
provider "google" {
credentials = "${file("../secrets/account.json")}"
project = "that-big-universe"
region = "us-central1"
}
- Filename:
addresses.tf
This file will include the resources for the static IPs for use with the server and assigning a subdomain within the DNS Zone to redirect.
resource "google_compute_address" "nginx-server" {
name = "nginx-server"
}
- Filename:
zone-adronme.tf
This file has more than the entries below, such as for this very blog. But I’ve just included the specifics of what are needed to provide the subdomain that will direct to the server, which will then provide the redirect.
resource "google_dns_managed_zone" "adronme" {
name = "adronme"
dns_name = "adron.me."
description = "Production http://adron.me Domain."
}
resource "google_dns_record_set" "data" {
managed_zone = "${google_dns_managed_zone.adronme.name}"
name = "data.${google_dns_managed_zone.adronme.dns_name}"
type = "CNAME"
ttl = 5
rrdatas = ["${google_compute_address.nginx-server.address}"]
}
Note that the rrdatas value of google_compute_address.nginx-server.address
references whatever static IP is created in the addresses.tf
file resource.
That will give me the DNS entries needed to get any requests sent to the actual server from within Google Cloud using their respective DNS Server & static IP assigned for their network.
The next thing I want now is the actual server that Nginx will be installed on. I don’t want Terraform just to whimsically make this Nginx Server from scratch though (which it could through scripts, etc). I know what needs to be on the server, namely Nginx, but also how it should be configured by default. I already have my actual redirect, so I want to just have the data baked into the image. The easiest way to insure Terraform builds a Virtual Machine in a repeatable way is to simply create an image in Google Cloud first. That way I can use that as the base of the virtual machine whenever it needs created. The way I generally manage this, is I simply create a folder within the repository called packer.
In the packer directory I’ll now have three specific files: install-nginx.sh, nginx.conf, and redirector.json. The install-nginx.sh will be for installing nginx, but will also include installing and opeing up the appropriate connections to the local firewall. The nginx.conf file will be the custom nginx file used for our nginx server that includes the URL redirection. This file will also be copied into the appropriate directory during creation of the image by the install-nginx.sh file. Last, the redirector.json file is the actual packer template that will be used to create the image. Below are the three files.
- Filename:
install-nginx.sh
This starts out by running the apt-get update, then installing UFW. UFW stands for Uncomplicated FireWall. After that is done, two allowances are added to the firewall for 22 (ssh) and 80 (http) traffic. Then it is enabled by passing in “y” to the command execution of sudo ufw enable
. After that is setup, nginx is installed and the service stopped. The service doesn’t really need stopped, but I’ll have to start it or restart it again in a moment so I stop it anyway. Then I’ve got the sudo update-rc.d nginx defaults
to set nginx to start upon reboots of the instance, finally the nginx.conf file from the repo is moved to replace the default nginx.conf file included with the original installation. Then finally a command to start nginx back up.
#!/usr/bin/env bash
# Install the UFW (Uncomplicated Firewall), setup tcp 22 and 80 for ssh and http. Then enable the firewall.
sudo apt-get update
sudo apt-get install ufw
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
echo "y" | sudo ufw enable
# Install nginx, stop, start, and restart the server for verification. Then set startup defaults.
sudo apt-get -y install nginx
sudo service nginx stop
sudo update-rc.d nginx defaults
sudo mv nginx.conf /etc/nginx/nginx.conf
sudo service nginx start
- Filename:
nginx.conf
This is the simple nginx.conf file, trimmed down to the bare necessities to accomplish the goal of redirecting this singular subdomain of http://data.adron.me to the URL in the file. Everything else in the file is default from the original installation. The key part with the URL redirection is toward the bottom of the file in the server
block. For now, until I make the redirect permanent, I’ve set it up simply as a 302 redirect.
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
server_name data.adron.me;
return 302 http://api.compositecode.com/dataservices/information.html;
}
}
- Filename:
redirector.json
This final file, the redirector.json file, is the packer template itself. The first section holds two variables, which I didn’t technically need, but when I expand on usage it comes in handy. Also, this way any names or such that I might want to change are at the top of the file. It makes it a little simpler to find the parts I change regularly during troubleshooting and getting everything to work.
After the two variables is the builders
section of the template. It includes what type of of builder it is (googlecompute), where that security file is (which I mentioned in the connection above for the terraform files, but this is connecting the packer template to the appropriate security key file), project id, zone, instance name, image name, and a few other values. A few of these values are very important to understand what they’re for and why I’ve put them here. The three I need to point out are instance_name
, image_name
, and ssh_username
.
The instance name is exactly what you might think, it’s the name of the instance that runs in Google Cloud Engine. However, this is the instance name of the instance that will be used temporarily to build the image from. That’s where the next value comes into place, the image_name
. The instance is deleted once it’s done being created, disconnected form the image that was created to build the instance, and that image is named whatever value is in the image_name
. So you’ll never really see the instance_name
except for a few moments during creation.
The third value, the ssh_username
is actually the username of the account created to run the shell scripts and do the installations and such. For some of the operating system types, this is necessary and others it is not. For the debian-8-jessie-v20160803 image I’ve set as the source_image
, it seems to be necessary based on my testing.
{
"variables": {
"instance_name": "redirector-{{timestamp}}",
"image_name": "redirector-{{timestamp}}"
},
"builders": [
{
"type": "googlecompute",
"account_file": "../../secrets/account.json",
"project_id": "that-big-universe",
"source_image": "debian-8-jessie-v20160803",
"zone": "us-central1-a",
"instance_name": "{{user `instance_name`}}",
"image_name": "{{user `image_name`}}",
"image_description": "Nginx Server.",
"communicator": "ssh",
"ssh_username": "nginxadmin"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 3",
"echo \"slept for 3 seconds.\""
]
},
{
"type": "file",
"source": "nginx.conf",
"destination": "nginx.conf"
},
{
"type": "file",
"source": "install-nginx.sh",
"destination": "install-nginx.sh"
},
{
"type": "shell",
"script": "install-nginx.sh",
"pause_before": "10s"
}
]
}
Where we’re at…
At this point I’ve got the key elements ready for deploy to Terraform and I’ve got the core pieces to build the image with my template for Packer. But I’ve got neither of these tools actually installed just yet. Well, I’m in luck, I’ve created two scripts just for this purpose for OS-X and Linux. Oh wait, I might have lied, I only have install files for OS-X and Linux. If you’re running Windows just navigate out and follow these instructions for Terraform on Windows and Packer on Windows.
Alright, with Packer and Terraform installed, I’m ready to build some networking infrastructure and a base image. The first thing I do is run the Packer command, from the directory in which I created the three files related to my Nginx Server. The following is an animated .gif recording (made with licecap) of running packer build redirector.json
. Note, I paused over some of the parts that take a few seconds, so just the actual changes are shown without the long delays over things like deleting instance or creating image steps. So don’t freak out when you run a packer build and some things take a few seconds or minutes.
Now that we have the packer built image in Google Cloud I can build the Nginx server using this image. Here’s what I put together for the Terraform file to create the Nginx server. Note, I’ve placed this file in the root of the project repository (where I’ve placed all of my Terraform files that I mentioned previously in this article).
- Filename:
redirector.tf
In this file I’ve declared a Terraform Compute Instance type, and named it redirector. For the disk, I’ve set it to the image name that Packer created for me, then the network_interface has an access_config that has the nat_ip set to the .address of the redirector static IP. Previously in the article I setup the DNS to point http://data.adron.me to that IP address, so this is the final step here. The other information in the Terraform Template, suffice it to say, is a topic for another day. I will mention however, that the tags “http-server” and “https-server” are there to ensure that the Google Firewalls are appropriately opened up to these ports (80 and 443 respectively). Albeit I’m not using 443 at the moment, it’s open for subsequent material I may write on this topic.
resource "google_compute_instance" "redirector" {
name = "redirector"
machine_type = "f1-micro"
tags = [
"http-server",
"https-server"]
zone = "us-central1-b"
disk {
image = "redirector-1471307522"
}
network_interface {
network = "default"
access_config {
nat_ip = "${google_compute_address.redirector.address}"
}
}
service_account {
scopes = [
"userinfo-email",
"compute-ro",
"storage-ro"]
}
}
Now, I can use the Terraform CLI and it’ll pull in the all the .tf files for processing and build out the static IP, DNS entry, and respective instance with the nginx.conf file already baked in. With a single command of terraform apply
and it will all be done!
Now, of course the first time this is applied, be sure to give the DNS Servers some time to propagate. When done, the URL redirection will be in place.
If you see any errors or confusing parts of this article or part 1 let me know. You can even take it a step further and fork my repo and, make the changes to the markdown file here and submit a pull request. I’ll review and get a new static site built with the edits ASAP! Thanks.


Wabi-Sabi
In traditional Japanese aesthetics, wabi-sabi is a world view centered on the acceptance of transience and imperfection. The aesthetic is sometimes described as one of beauty that is “imperfect, impermanent, and incomplete.”
Based on doodles-site-example.webflow.io
|


Gulp boilerplate
Front-end boilerplate for a better and faster workflow
style guidelines
0 times clicked


The Seamless shareserver
The purpose of the shareserver is that you can share cell values over HTTP. That means that you can see the cell value when you type its URL in your browser. In addition, if you use a Seamless project, a web interface is automatically generated from all shared cells. By default, shared cells are readonly, and can only be visualized. Shared cells with readonly disabled can also be edited via a web interface.
IMPORTANT: This documentation section is an early draft. The raw text material is shown below
Relevant examples:
The shareserver is to share Seamless cells via its REST API. By default, the REST port is 5813 In addition, the shareserver sends notifications via Websocket connections, served at port 5138 The primary ways to interact with the share server are:
The browser, for GET requests. http://localhost:5813/ctx/a will get the value of cell “a”, if it has been shared
The seamless-http-put command, for PUT requests.
The seamless client (seamless-client.js)


ciphercloud
Businessmodel of CipherCloud
Customer Segments
CipherCloud offers cloud security services to clients operating in a number of commercial sectors. This includes customers across the following industries:
- Banking and Financial Services, including a range of banking institutions, investment managers, insurance companies, credit institutions, and other financial service providers;
- Communications, including telecommunications companies, internet service providers, cable network operators, and mobile network operators;
- Technology, including high technology companies, software companies, IT service providers, and other technology businesses;
- Healthcare and Pharmaceutical, including healthcare providers, pharmaceutical companies, life science companies, and medical technology companies;
- Manufacturing, including manufacturers of various consumer goods, industrial parts, and other products and components; and
- Government, including municipal, state, and federal government bodies, as well as various public agencies. CipherCloud is based in the US, which is also its principal market. The Company also serves an international client base that includes customers across markets in the Americas, Europe, and Asia Pacific.
Value Propositions
CipherCloud provides value to its clients in the following ways:
- Its industry standing and reputation, with the Company established as a popular provider of cloud security solutions, maintaining an extensive client base that includes market leading companies across a number of business sectors;
- Its proprietary technologies, with the Company developing and utilising proprietary technologies in the creation of delivery of its security solutions, making its service offerings unique within the industry;
- The security and reliability of its solutions, with the Company offer solutions that ensure the privacy and security of its clients’s information, protecting data across its entire lifecycle spanning discovery, encryption, data loss protection, and ongoing monitoring;
- Its international sales and service reach, with the Company serving an extensive domestic client base in the US, in addition to a large international client base spanning markets in the Americas, Asia Pacific, and Europe; and
- Its specialist personnel, with the Company employing specialist cloud security personnel, as well as a team of experienced technology industry executives. ### Channels
CipherCloud operates a website at www.ciphercloud.com, through which it offers information on its various solutions, services, and operating locations. While the Company does not appear to operate an online sales channel, it does allow customers to arrange free trials through its website. The Company additionally offers mobile applications that can be downloaded directly from the Apple App Store and the Google Play Store.
CipherCloud makes the bulk of its sales through an in-house direct sales force, which is organised across the Company’s various operating regions. These sales personnel operate out of the Company’s international network of offices, including the Company’s regional headquarters in Maidenhead, UK; Sydney, Australia; Hyderabad, India, and Tokyo, Japan. CipherCloud additionally utilises the services of various channel and distribution partners. This includes resellers, distributors, and independent sales agents.
Customer Relationships
CipherCloud does not offer its products and services to customers on a self-service basis. The Company does, however, enable customers to register an interest in its products directly through its website without interacting directly with sales and service personnel. The Company’s mobile applications are also available for download on a self-service basis.
CipherCloud operates a direct sales force across the Americas, Europe, and Asia Pacific. The Company’s direct sales personnel consult closely with client representatives to ensure that solutions are scaled and tailored appropriately to the individual needs of each client, and that their specific needs are met. CipherCloud seeks to establish longstanding relationships with its clients, with its security solutions designed to integrate closely with the systems of its customers.
CipherCloud continues to offer ongoing support services to its clients. Customers are able to contact dedicated support personnel online or over the phone in order to receive personalised assistance. The Company’s largest clients are also afforded their own account management teams that they are able to contact directly. Additionally, CipherCloud provides an extensive range of online resources- including webinars, FAQs, papers, blog posts, and videos – that can be accessed by clients directly through the Company’s website.
CipherCloud interacts directly with customers, and publishes company updates, through its social media accounts, including with Twitter, LinkedIn, and YouTube.
Key Activities
CipherCloud is a cloud security provider. It is engaged primarily in the development and provision of a multi-cloud security platform that integrates data protection, content control, monitoring, cloud discovery, and risk analysis tools.
The Company offers a range of related solutions that relate to the areas of activity monitoring, data loss prevention, encryption, tokenisation, key management, malware and threat detection, and data monitoring, as well as implementation services, enablement programs, training and certification, and customer support.
CipherCloud serves commercial customers across a range of industries, including the financial services, healthcare, technology, manufacturing, telecommunication, and government sectors. The Company serves an international client base, including customers across North America, Europe, South America, and Asia.
Key Partners
CipherCloud works closely with a network of partner companies and organisations to ensure that it develops reliable solutions and effective implementation channels. These partners can be organised broadly into the following categories:
- Supplier and Vendor Partners, including suppliers of services, equipment, and technologies that are utilised by the Company in the development and implementation of its cloud security solutions;
- Cloud Partners, including a range of cloud software-as-a-service and platform-as-a-service providers, including a number of high-profile online companies, with which the Company integrates cloud security features and develops effective cloud solutions;
- Channel and Distribution Partners, including the Company’s network of resellers, distributors, and sales agents that assist in extending the Company’s sales and marketing reach;
- Technology and Development Partners, including high-profile technology companies, IT service providers, and software developers, with which the Company collaborates on developing effective joint solutions; and
- Strategic and Alliance Partners, including companies and consultants across multiple sectors, with which the Company collaborates on a range of joint projects, including in marketing, branding, and development. CipherCloud names a number of its cloud partners on its website. This includes well-known technology companies such as Box, Dropbox, Salesforce, SAP, Adobe Analytics, Google Drive, One Drive, and SharePoint.
Key Resources
CipherCloud’s key resources are its proprietary technologies and intellectual properties, its cloud security platform and solutions, its IT and communications infrastructure, its sales and distribution channels, its network of partners – in particular its large cloud service partners, its, and its personnel.
CipherCloud utilises various proprietary technologies that it uses the ensure the security and privacy of its clients. Searches of records published by the US Patent and Trademark Office identified a number of separate patent applications filed in CipherCloud’s name under the title ‘System and method to anonymize data transmitted to a destination computing device’.
In addition, CipherCloud owns and or leases a number of physical properties around the world that comprise its network of sales and administrative offices.
Cost Structure
CipherCloud incurs costs in relation to the development of its technologies and intellectual properties, the development and maintenance of its security solutions and online platform, the maintenance of its IT and communications infrastructure, the procurement of services, the management of its key partnerships, the implementation of marketing and advertising campaigns, and the retention of its personnel.
Revenue Streams
CipherCloud generates revenue through the development and provision of cloud security solutions. This principally comprises revenue derived in the form of subscriptions and sales in relation to its flagship cloud security platform. The Company also derives a portion of its revenue under contracts relating to its ancillary services.
CipherCloud remains a privately owned company, and as such is not obliged to publish its financial results online. Research did not identify any media coverage of the Company’s revenue figures. A corporate directory, however, suggests that the Company generates annual revenue of approximately $24.8 million.


{% extends "sentry/projects/manage.html" %} {% load i18n %} {% block inner %}
|
{{ rule.label }} {% if rule.conditions %} When
{% for condition in rule.conditions %}
{{ condition }} {% endfor %} {% endif %} {% if rule.actions %} Do
{% for action in rule.actions %}
{{ action }} {% endfor %} {% endif %} |
Delete |
You have not yet created any rules. Rules allow you to tweak the behavior of Sentry in various situations, such as sending notifications.
{% endif %} {% endblock %}


Here some examples
What is a type? It defines what a device is by defining its properties, functions and statuses. Learn more in the dev center if you are curious about.
Connect your physical device so that you can start building the connected home or simulate the device behaviour. If you don't know how to connect a physical device you can learn how to connect your first light.
Simulate the physical device (no hardware needed).
Connect your physical device using MQTT (learn more).
Set the URI that identify your device (learn more).


Hey there! Here you can import an existing API to the Studio by either giving us the OpenAPI document or telling us where we can get it.
Choose from the following options:


{% extends 'templated-base.html' %} {% block content %}
We have attempted to send an email to {{email}}. Please verify your email address by clicking on the link in the email and activate your account.


A front-end toolkit for rapidly developing web applications. It is a collection of CSS and HTML conventions that uses some of the latest browser techniques.
Designed to fit on all mobile and tablet devices such as iPads and iPhones. Let your visitors try it on their devices or even you and see the results.
In addition to predefined skin color feature, this template is built to easily customize and add your own color scheme based on what color you like.
One of the features of Shamcey is Media Manager which uses Isotope for sorting media files. This Isotope plugin can hide/show and reorder items with awesome effects.
Another unique features of Shamcey is adding the TinyMCE WYSIWYG Editor that is very easy to integrate with awesome custom styles added by the author.
This template uses one of the most stunning icons in the internet whic are the IconGlyphs, Font Awesome and IconSweets with some added examples.
Shamcey has 5 predefined skins for you to use and with that you can add your own skins easily by referring to the predefined skins that added in this template.
Shamcey is using Modernizr to easily detect browser support and make it compatible to all modern browsers such as Firefox, Chrome, Safari, and IE 8 up to IE 10.
This template also uses more jQuery plugins such as bxSlider, Spinner, slimScroll, smartWizard, FullCalendar , jQuery Uniform, jQuery Validation and muc more...