<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openuru.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Leonardo</id>
	<title>OpenUru - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openuru.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Leonardo"/>
	<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php/Special:Contributions/Leonardo"/>
	<updated>2026-10-23T11:12:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cyan_Content_Licensing_Proposals&amp;diff=1778</id>
		<title>Cyan Content Licensing Proposals</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cyan_Content_Licensing_Proposals&amp;diff=1778"/>
		<updated>2012-02-15T16:00:32Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* Signatures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Content Licensing Request ==&lt;br /&gt;
===  Introduction ===&lt;br /&gt;
Open source is succeeding as the community provides its first tested update to MOULa. We are directly experiencing the next challenge in our progress toward &amp;quot;Open Uru,&amp;quot; Open Uru being what is created by code, content, creativity and participation. The ability to work with and distribute MOULa content under license will determine what we can and cannot do for the future of the Cyan Worlds Engine and MOULa. Working with content will in large part be responsible for increasing the interest and participation of developers, artists, and players to create a broader audience.&lt;br /&gt;
&lt;br /&gt;
We are not attempting a complete statement of the aspirations of the fans with respect to MOULa content licensing. This is an exemplar of specific cases representative of fan efforts to improve MOULa for the community where it is hindered by the absence of a suitable license for the adaptation and distribution of MOULa content. These examples are used as a means to explore the licensing possibilities with Cyan Worlds and to elicit feedback on its own potential difficulties so that we might collectively establish a way forward.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
* Localization - Cyan Worlds, Myst, Uru and MOULa all have an international audience. MOULa has an extensible localization system that allows content creators to provide translated text automatically. Unfortunately, many of the dialogs currently in MOULa don't take advantage of this capability and cannot be adapted properly without modifying them. GULP (formerly the Uru Localization Project) has a database of community-contributed translations in a large number of languages. H'uru has done Unicode development to allow non-US keyboards.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Derivation - We have textures and limited content (KI and avatars) but they are unlicensed. We cannot distribute work such as scrollbars for the KI for the community to enjoy. We would like to be able to create, serve, test, and contribute work that is consistent with existing MOULa ages for eventual inclusion on MOULa.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Distribution - Shards cannot serve binary MOULa content files. This raises the barrier against non-technical users faced with manually copying MOULa content to their shard folder as part of the shard install. The technical support load is increased, creating barriers of time, effort and cost for shard owners as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Improvements - MOULa ages cannot be repaired by fans to function as designed. For example, a player who links to AhnonayCathedral always finds the automatic door closed while at the same time players who are already there see it wide open. The fix requires a change in the .prp file which currently calls the door responders directly instead of calling an intermediate Python file. We need a content license to change, test and distribute .prp files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Community Needs ===&lt;br /&gt;
&lt;br /&gt;
There are two primary allowances we need from Cyan Worlds to continue efforts to expand MOULa's accessibility:&lt;br /&gt;
&lt;br /&gt;
* A permissive license to allow copying, translation, and distribution of information available in MOULa. For example, the .loc and .prp files. This would legalize, for example, the translation work already done by the community and enable its distribution and enjoyment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Access to 3ds Max source files for GUIs or other useful materials used in MOULa to normalize their use of the provided hooks in the code which they currently do not use, and a license to redistribute at least the compiled output with fixes applied. If that is impossible, an alternative is a license to modify and distribute existing .prp files containing fixes or new features such as translatable GUI items.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Questions ===&lt;br /&gt;
&lt;br /&gt;
* Is Cyan Worlds able to indicate what difficulties there are in licensing MOULa content?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Are there any particular aspects to content release issues where Cyan Worlds is open to suggestions?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Are there specific limitations that fans should place on their hopes for content licensing?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Can Cyan Worlds indicate if unreleasable content will become available in the future or under other circumstances?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
We have presented collaborative concerns about the problems the community seeks to resolve regarding content licensing. We believe Cyan Worlds knows best what solutions are available to it. We hope this will be a successful collaborative path to a general solution.&lt;br /&gt;
&lt;br /&gt;
The representative community members who sign below collaborated to discuss and contribute to this letter of many authors. Thank you for reading and considering this request.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This document's history on the wiki: http://wiki.openuru.org/index.php?title=Cyan_Content_Licensing_Proposals&lt;br /&gt;
&lt;br /&gt;
Full discussion on the OpenUru.org forums: http://forums.openuru.org/viewtopic.php?f=91&amp;amp;t=635&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Signatures ===&lt;br /&gt;
[[User:OHB|OHB]] 19:24, 2 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Hoikas|Hoikas]] 19:31, 2 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Branan|Branan]] 21:08, 2 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Christian Walther|Christian Walther]] 05:28, 3 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Leonardo|Leonardo]] 06:16, 3 February 2012 (MST), guildofmessengers.com&lt;br /&gt;
&lt;br /&gt;
[[User:Mac Fife|Mac Fife]] 12:12, 3 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Nadnerb|Nadnerb]] 14:36, 3 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Malfhok|Malfhok]], an explorer 05:14, 4 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Deledrius|Deledrius]] 08:57, 4 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Marten|Marten]] 09:44, 5 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:D'Lanor|D'Lanor]] 00:00, 8 February 2012 (CET)&lt;br /&gt;
&lt;br /&gt;
[[User:GPNMilano|GPNMilano]] 23:36, 8 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:JWPlatt|JWPlatt]] 10:51, 15 February 2012 (EST), Jonathan W. Platt, OpenUru.org, (Address TBI)&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is additional technical information.&lt;br /&gt;
&lt;br /&gt;
=== Technical Information ===&lt;br /&gt;
The .loc files are XML files containing translations for all textual items in Uru. GULP (http://rel.to/gulp) already has an extensive library of translations and a system to export that database to Uru-ready .loc files. Not all of Uru uses these however, as some values are hard-coded in Python scripts or the PRPs themselves, but this can be converted as the GUI items have the ability to reference the XML paths directly. Much of this Python code references the GUI items by TagIDs, which are arbitrary unique numbers used to refer to the resource. This is messy, as it must be updated when the GUI is updated and can otherwise become out of sync; it is also problematic in the current data set as not all translatable GUI items have been assigned TagIDs, meaning they must be found (if at all) by very fragile code. There is also an embedded text field in these items, which currently contains only the English text. Fortunately, these items support a self-describing LocalizationPath which automatically informs the Plasma engine's LocalizationManager which string to use, allowing localization to be handled cleanly and consistently. All of these items are a part of the data and without a license to modify and distribute the PRPs, we cannot continue the efforts to localize Uru outside of using hacks and shims to the existing elegant but under-utilized engine.&lt;br /&gt;
&lt;br /&gt;
As an additional benefit to Cyan: the changes made under the proposed licensing could be relatively easy for Cyan to integrate back into their own assets without affecting current functionality. This would be impossible if only binary changes are allowed to the exported PRPs rather than the .max sources, and it allows Cyan to take advantage of the localization code changes in the engine once it reaches maturity in the community testing with very little friction.&lt;br /&gt;
&lt;br /&gt;
An extra note about the alternative suggestion in (2) which only allows modification of PRPs -- The reason this is inferior, aside from the obvious, is that while it would allow the immediate goal of activating the built-in localization, I anticipate minor bugs such as text flow and sizing in the UI when displaying languages other than the one for which they were designed. These will be extremely difficult to fix under the limited alternative solution and should be far simpler with access to the original 3D Studio Max source files.&lt;br /&gt;
&lt;br /&gt;
=== License Suggestions ===&lt;br /&gt;
I was going to wrap up by suggesting licenses in order to simplify the burden on Cyan, but as the OU Content Licensing thread proves there are many viable options and they all address different needs. Unfortunately, in order to find where that spot of compromise is we'll need feedback from Cyan on this point. I implore Cyan, should they wish to consider this request, to respond with their concerns and needs first. At that point tangible suggestions can be made regarding the specifics and the proposal can move forward should they be agreeable.&lt;br /&gt;
&lt;br /&gt;
At any rate, for the .loc files I'd suggest terms which preserves Cyan's ownership of the text (some of which, being canon from the Myst universe, has inherent value to them), while allowing edits and distribution by the community. A disclaimer stating that Cyan is only responsible for the original English text may also be desirable.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
Forum link: [http://forums.openuru.org/viewtopic.php?f=91&amp;amp;t=635 Content Licensing]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cyan_Content_Licensing_Proposals&amp;diff=1719</id>
		<title>Cyan Content Licensing Proposals</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cyan_Content_Licensing_Proposals&amp;diff=1719"/>
		<updated>2012-02-03T13:16:32Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* Signatures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Localization Licensing Request ==&lt;br /&gt;
===  Problem Statement ===&lt;br /&gt;
==== Preface ====&lt;br /&gt;
Please note that this is not a complete statement of the aspirations of the fan developers in respect of Uru/MOUL content licensing; rather it is an exemplar of a specifc case where fan developer efforts to improve Uru/MOUL for the community are hindered by the absence of a suitable license for the adaptation and distribution of Cyan's content. This example is used a means to explore the licensing possibilities with Cyan and to elicit feedback on potential difficulties so that we might collectively establish a way forward.&lt;br /&gt;
&lt;br /&gt;
==== Introduction ====&lt;br /&gt;
Uru has an international audience, and an extensible Localization system which allows content creators to provide translated text to be utilized automatically. Unfortunately, many of the dialogs currently in Uru don't take advantage of this capability and cannot be adapted to do so properly without modifying them.&lt;br /&gt;
&lt;br /&gt;
==== What the Community Has Accomplished Thus Far ====&lt;br /&gt;
Thanks to the efforts of everyone at GULP (http://rel.to/gulp, formerly the Uru Localization Project), we have a database of translations in a large number of languages. Changes have been made to the code re-enabling the functions which had been disabled after Untìl Uru, as well as fixes in the input routines that now allow non-US keyboards.&lt;br /&gt;
&lt;br /&gt;
==== What the Community Needs to Continue ====&lt;br /&gt;
There are two primary allowances we need from Cyan in order to continue our efforts to expand Uru's accessibility:&lt;br /&gt;
# A permissive license that would allow us to copy, translate, and distribute all textual information available in Uru, currently located in the .loc files. This would legalize translations and allow their distribution, a necessary step to put all of the community's work into use.&lt;br /&gt;
# Access to the 3ds Max source files for all GUIs used in Uru so that we can normalize their use of the provided hooks in the code which they currently do not use, and a license to re-distribute at least the compiled output with those fixes applied. If that is deemed impossible, an inferior solution that would allow at least this specific goal is a license to modify and distribute the existing PRPs containing translatable GUI items.&lt;br /&gt;
&lt;br /&gt;
At this time, we would ask if Cyan are able to indicate what difficulties they forsee over the licensing of content; if there are particular aspects where Cyan are open to suggestions; if there are specific limitations which the fans should place on their aspirations for content licensing.&lt;br /&gt;
&lt;br /&gt;
Thank you for reading and considering this request.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Following is additional technical information.&lt;br /&gt;
&lt;br /&gt;
=== Technical Information ===&lt;br /&gt;
The .loc files are XML files containing translations for all textual items in Uru. GULP (http://rel.to/gulp) already has an extensive library of translations and a system to export that database to Uru-ready .loc files. Not all of Uru uses these however, with some values hard-coded in Python scripts or the PRPs themselves, but this can be converted as the GUI items have the ability to reference the XML paths directly. Much of this Python code references the GUI items by TagIDs, which are arbitrary unique numbers used to refer to the resource. This is messy, as it must be updated when the GUI is updated and can otherwise become out of sync; also it is problematic in the current data set as not all translatable GUI items have been assigned TagIDs, meaning they must be found (if at all) by very fragile code. There is also an embedded text field in these items, which currently contains only the English text. Fortunately, these items support a self-describing LocalizationPath which automatically informs the Plasma engine's LocalizationManager which string to use, allowing localization to be handled cleanly and consistently. All of these items are a part of the data and without a license to modify and distribute the PRPs, we cannot continue with the efforts to localize Uru outside of hacks and shims to the existing elegant but under-utilized engine.&lt;br /&gt;
&lt;br /&gt;
As an additional benefit to Cyan: the changes made under the proposed licensing could be relatively easy for Cyan to integrate back into their own assets without affecting current functionality. This would be impossible if only binary changes are allowed to the exported PRPs rather than the .max sources, and it allows Cyan to take advantage of the localization code changes in the engine once it reaches maturity in the community testing with very little friction.&lt;br /&gt;
&lt;br /&gt;
An extra note about the inferiority of the secondary suggestion in (2) which only allows modification of PRPs -- The reason I mention this is inferior, aside from the obvious, is that while it would allow the immediate goal of activating the built-in localization, I anticipate minor bugs such as text flow and sizing in the UI when languages other than the one for which they were designed are used. These will be extremely difficult to fix under the limited solution mentioned and should be far simpler under the ideal of having access to the original 3D Studio Max source files.&lt;br /&gt;
&lt;br /&gt;
=== License Suggestions ===&lt;br /&gt;
I was going to wrap up by suggesting licenses in order to lighten the load on Cyan, but as the OU Content Licensing thread proves there are many viable options and they all address different needs. Unfortunately, in order to find where that spot of compromise is we'll need feedback from Cyan on this point. I implore Cyan, should they wish to consider this proposal, to respond with their concerns and needs first. At that point tangible suggestions can be made regarding the specifics and the proposal can move forward should they be agreeable.&lt;br /&gt;
&lt;br /&gt;
At any rate, for the .loc files I'd suggest terms which preserves Cyan's ownership of the text (some of which, being canon from the Myst universe, has inherent value to them), while allowing edits and distribution by the community. A disclaimer stating that Cyan is only responsible for the original English text may also be desirable.&lt;br /&gt;
&lt;br /&gt;
=== Links ===&lt;br /&gt;
Forum link: [http://forums.openuru.org/viewtopic.php?f=91&amp;amp;t=635 Content Licensing]&lt;br /&gt;
&lt;br /&gt;
=== Signatures ===&lt;br /&gt;
[[User:OHB|OHB]] 19:24, 2 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Hoikas|Hoikas]] 19:31, 2 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Branan|Branan]] 21:08, 2 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Christian Walther|Christian Walther]] 05:28, 3 February 2012 (MST)&lt;br /&gt;
&lt;br /&gt;
[[User:Leonardo|Leonardo]] 06:16, 3 February 2012 (MST)&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1317</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1317"/>
		<updated>2011-10-18T20:16:01Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* jQuery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
** jsonp : Provides the output in JSON-P (Javascript Object Notation with Padding) format, intended for javascript/jQuery users. See the additional notes below on using this option.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== JSON-P ===&lt;br /&gt;
Setting the type argument in a request to &amp;quot;jsonp&amp;quot; will return output formatted for Javascript Object Notation with Padding, essentially an object of data passed to a callback function. This method is essential if you are trying to fetch the CAVCON data with javascript (due to the same-origin-policy applied by most browsers). To know more about JSONP, its usage and the reason of its existance read [http://en.wikipedia.org/wiki/JSONP Wikipedia's Article].&lt;br /&gt;
When using this option, it is also necessary to specify the function name of the callback procedure that will parse the returned array in the client, so a second argument, jsoncallback, must be supplied as in the following example:&lt;br /&gt;
:http://www.openuru.org/tools/cavstat.php?type=jsonp&amp;amp;jsoncallback=anyFunctionName&lt;br /&gt;
Note that the name of the callback function is not important as far as the server is concerned, but it '''must''' be supplied otherwise an error message will be returned.&lt;br /&gt;
&lt;br /&gt;
In response, the server will return data similar to the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
anyFunctionName({&amp;quot;LED&amp;quot;: &amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;, &lt;br /&gt;
&amp;quot;State&amp;quot;: &amp;quot;Open for exploration!&amp;quot;, &amp;quot;Link&amp;quot;: &amp;quot;Sign up to play at MystOnline.com!&amp;quot;, &lt;br /&gt;
&amp;quot;LinkURL&amp;quot;: &amp;quot;http://mystonline.com/play/&amp;quot;, &amp;quot;Message&amp;quot;: &amp;quot;Welcome to Myst Online: Uru Live! &lt;br /&gt;
Bug Chucker now available on Android Marketplace!&amp;quot;, &amp;quot;Origin&amp;quot;: &amp;quot;www.openuru.org&amp;quot;, &lt;br /&gt;
&amp;quot;OriginURL&amp;quot;: &amp;quot;http://www.openuru.org/&amp;quot;}) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarity, the array returned in the padded object consists of the following members:&lt;br /&gt;
* &amp;quot;LED&amp;quot;: A URL to the applicable colored status &amp;quot;lamp&amp;quot;; red green or yellow,&lt;br /&gt;
* &amp;quot;State&amp;quot;: Text string indicating the state of the cavern,&lt;br /&gt;
* &amp;quot;Link&amp;quot;: Text message intended to be used as anchor text for LinkURL,&lt;br /&gt;
* &amp;quot;LinkURL&amp;quot;: URL to the current MOULa sign-up/play page at mystonline.com,&lt;br /&gt;
* &amp;quot;Message&amp;quot;: The Cyan developer message, as shown on the MOULa startup dialogs,&lt;br /&gt;
* &amp;quot;Origin&amp;quot;: Text message intended to be used as anchor text for OriginURL.&lt;br /&gt;
* &amp;quot;OriginURL&amp;quot;: URL of the site that the status message has been delivered from.&lt;br /&gt;
There is no requirement that the end user implements all of these, or that they represent them in any particular manner giving the page designer complete freedom to manage the usage, format and layout as best suits their intended page layout.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
The following code can be used to dynamically update the cavern widget on a webpage. This is an independent code, it does not need the PHP code above, just include the jQuery library in your webpage.&lt;br /&gt;
&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'http://www.openuru.org/tools/cavstat.php',&lt;br /&gt;
    data: 'type=jsonp',&lt;br /&gt;
    dataType: 'jsonp',&lt;br /&gt;
    jsonp: 'jsoncallback',&lt;br /&gt;
    crossDomain: true,&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the data received from OpenUru&lt;br /&gt;
      output='&amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&amp;lt;img src=&amp;quot;'+data.LED+'&amp;quot;&amp;gt; '+data.State+'&amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt; - &amp;lt;a href=&amp;quot;'+data.LinkURL+'&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt; '+data.Link+'&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; '+data.Message+' &amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;'+data.OriginURL+'&amp;quot;&amp;gt;'+data.Origin+'&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;';&lt;br /&gt;
      $(el).html(output);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the code above you can see the ''output'' variable that contains the HTML code that will be generated in your web page, you can customize it to follow your website design or preferences. To know more about the member variables of the ''data'' object please consult the section ''JSONP'' above.&lt;br /&gt;
Optionally you can insert some error handling code in the error function, where we placed just a comment.&lt;br /&gt;
&lt;br /&gt;
Call the CavernStatus function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Call it every X seconds to make the widget update dynamically.&lt;br /&gt;
In this example we assume the id of the element that will contain the Cavern Status Widget is &amp;quot;widget&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1316</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1316"/>
		<updated>2011-10-18T19:51:14Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* jQuery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
** jsonp : Provides the output in JSON-P (Javascript Object Notation with Padding) format, intended for javascript/jQuery users. See the additional notes below on using this option.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== JSON-P ===&lt;br /&gt;
Setting the type argument in a request to &amp;quot;jsonp&amp;quot; will return output formatted for Javascript Object Notation with Padding, essentially an object of data passed to a callback function. This method is essential if you are trying to fetch the CAVCON data with javascript (due to the same-origin-policy applied by most browsers). To know more about JSONP, its usage and the reason of its existance read [http://en.wikipedia.org/wiki/JSONP Wikipedia's Article].&lt;br /&gt;
When using this option, it is also necessary to specify the function name of the callback procedure that will parse the returned array in the client, so a second argument, jsoncallback, must be supplied as in the following example:&lt;br /&gt;
:http://www.openuru.org/tools/cavstat.php?type=jsonp&amp;amp;jsoncallback=anyFunctionName&lt;br /&gt;
Note that the name of the callback function is not important as far as the server is concerned, but it '''must''' be supplied otherwise an error message will be returned.&lt;br /&gt;
&lt;br /&gt;
In response, the server will return data similar to the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
anyFunctionName({&amp;quot;LED&amp;quot;: &amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;, &lt;br /&gt;
&amp;quot;State&amp;quot;: &amp;quot;Open for exploration!&amp;quot;, &amp;quot;Link&amp;quot;: &amp;quot;Sign up to play at MystOnline.com!&amp;quot;, &lt;br /&gt;
&amp;quot;LinkURL&amp;quot;: &amp;quot;http://mystonline.com/play/&amp;quot;, &amp;quot;Message&amp;quot;: &amp;quot;Welcome to Myst Online: Uru Live! &lt;br /&gt;
Bug Chucker now available on Android Marketplace!&amp;quot;, &amp;quot;Origin&amp;quot;: &amp;quot;www.openuru.org&amp;quot;, &lt;br /&gt;
&amp;quot;OriginURL&amp;quot;: &amp;quot;http://www.openuru.org/&amp;quot;}) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarity, the array returned in the padded object consists of the following members:&lt;br /&gt;
* &amp;quot;LED&amp;quot;: A URL to the applicable colored status &amp;quot;lamp&amp;quot;; red green or yellow,&lt;br /&gt;
* &amp;quot;State&amp;quot;: Text string indicating the state of the cavern,&lt;br /&gt;
* &amp;quot;Link&amp;quot;: Text message intended to be used as anchor text for LinkURL,&lt;br /&gt;
* &amp;quot;LinkURL&amp;quot;: URL to the current MOULa sign-up/play page at mystonline.com,&lt;br /&gt;
* &amp;quot;Message&amp;quot;: The Cyan developer message, as shown on the MOULa startup dialogs,&lt;br /&gt;
* &amp;quot;Origin&amp;quot;: Text message intended to be used as anchor text for OriginURL.&lt;br /&gt;
* &amp;quot;OriginURL&amp;quot;: URL of the site that the status message has been delivered from.&lt;br /&gt;
There is no requirement that the end user implements all of these, or that they represent them in any particular manner giving the page designer complete freedom to manage the usage, format and layout as best suits their intended page layout.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
The following code can be used to dynamically update the cavern widget on a webpage. This is an independent code, it does not need the PHP code above, just include the jQuery library in your webpage.&lt;br /&gt;
&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'http://www.openuru.org/tools/cavstat.php',&lt;br /&gt;
    data: 'type=jsonp',&lt;br /&gt;
    dataType: 'jsonp',&lt;br /&gt;
    jsonp: 'jsoncallback',&lt;br /&gt;
    crossDomain: true,&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      output='&amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&amp;lt;img src=&amp;quot;'+data.LED+'&amp;quot;&amp;gt; '+data.State+'&amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt; - &amp;lt;a href=&amp;quot;'+data.LinkURL+'&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt; '+data.Link+'&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; '+data.Message+' &amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;'+data.OriginURL+'&amp;quot;&amp;gt;'+data.Origin+'&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;';&lt;br /&gt;
      $(el).html(output);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the code above you can see the ''output'' variable that contains the HTML code that will be generated in your web page, you can customize it to follow your website design or preferences. To know more about the member variables of the ''data'' object please consult the section ''JSONP'' above.&lt;br /&gt;
Optionally you can insert some error handling code in the error function, where we placed just a comment.&lt;br /&gt;
&lt;br /&gt;
Call the CavernStatus function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Call it every X seconds to make the widget update dynamically.&lt;br /&gt;
In this example we assume the id of the element that will contain the Cavern Status Widget is &amp;quot;widget&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1315</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1315"/>
		<updated>2011-10-18T19:49:28Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* jQuery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
** jsonp : Provides the output in JSON-P (Javascript Object Notation with Padding) format, intended for javascript/jQuery users. See the additional notes below on using this option.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== JSON-P ===&lt;br /&gt;
Setting the type argument in a request to &amp;quot;jsonp&amp;quot; will return output formatted for Javascript Object Notation with Padding, essentially an object of data passed to a callback function. This method is essential if you are trying to fetch the CAVCON data with javascript (due to the same-origin-policy applied by most browsers). To know more about JSONP, its usage and the reason of its existance read [http://en.wikipedia.org/wiki/JSONP Wikipedia's Article].&lt;br /&gt;
When using this option, it is also necessary to specify the function name of the callback procedure that will parse the returned array in the client, so a second argument, jsoncallback, must be supplied as in the following example:&lt;br /&gt;
:http://www.openuru.org/tools/cavstat.php?type=jsonp&amp;amp;jsoncallback=anyFunctionName&lt;br /&gt;
Note that the name of the callback function is not important as far as the server is concerned, but it '''must''' be supplied otherwise an error message will be returned.&lt;br /&gt;
&lt;br /&gt;
In response, the server will return data similar to the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
anyFunctionName({&amp;quot;LED&amp;quot;: &amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;, &lt;br /&gt;
&amp;quot;State&amp;quot;: &amp;quot;Open for exploration!&amp;quot;, &amp;quot;Link&amp;quot;: &amp;quot;Sign up to play at MystOnline.com!&amp;quot;, &lt;br /&gt;
&amp;quot;LinkURL&amp;quot;: &amp;quot;http://mystonline.com/play/&amp;quot;, &amp;quot;Message&amp;quot;: &amp;quot;Welcome to Myst Online: Uru Live! &lt;br /&gt;
Bug Chucker now available on Android Marketplace!&amp;quot;, &amp;quot;Origin&amp;quot;: &amp;quot;www.openuru.org&amp;quot;, &lt;br /&gt;
&amp;quot;OriginURL&amp;quot;: &amp;quot;http://www.openuru.org/&amp;quot;}) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarity, the array returned in the padded object consists of the following members:&lt;br /&gt;
* &amp;quot;LED&amp;quot;: A URL to the applicable colored status &amp;quot;lamp&amp;quot;; red green or yellow,&lt;br /&gt;
* &amp;quot;State&amp;quot;: Text string indicating the state of the cavern,&lt;br /&gt;
* &amp;quot;Link&amp;quot;: Text message intended to be used as anchor text for LinkURL,&lt;br /&gt;
* &amp;quot;LinkURL&amp;quot;: URL to the current MOULa sign-up/play page at mystonline.com,&lt;br /&gt;
* &amp;quot;Message&amp;quot;: The Cyan developer message, as shown on the MOULa startup dialogs,&lt;br /&gt;
* &amp;quot;Origin&amp;quot;: Text message intended to be used as anchor text for OriginURL.&lt;br /&gt;
* &amp;quot;OriginURL&amp;quot;: URL of the site that the status message has been delivered from.&lt;br /&gt;
There is no requirement that the end user implements all of these, or that they represent them in any particular manner giving the page designer complete freedom to manage the usage, format and layout as best suits their intended page layout.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
The following code can be used to dynamically update the cavern widget on a webpage. This is an independent code, it does not need the PHP code above, just include the jQuery library in your webpage.&lt;br /&gt;
&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'http://www.openuru.org/tools/cavstat.php',&lt;br /&gt;
    data: 'type=jsonp',&lt;br /&gt;
    dataType: 'jsonp',&lt;br /&gt;
    jsonp: 'jsoncallback',&lt;br /&gt;
    crossDomain: true,&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      output='&amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&amp;lt;img src=&amp;quot;'+data.LED+'&amp;quot;&amp;gt; '+data.State+'&amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt; - &amp;lt;a href=&amp;quot;'+data.LinkURL+'&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt; '+data.Link+'&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; '+data.Message+' &amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;'+data.OriginURL+'&amp;quot;&amp;gt;'+data.Origin+'&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;';&lt;br /&gt;
      $(el).html(output);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the code above you can see the ''output'' variable that contains the HTML code that will be generated in your web page, you can customize it to follow your website design or preferences. To know more about the member variables of the ''data'' object please consult the section ''JSONP'' above.&lt;br /&gt;
Optionally you can insert some error handling code in the error function, where we placed just a comment.&lt;br /&gt;
&lt;br /&gt;
Call the CavernStatus function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Call it every X seconds to make the widget update dynamically.&lt;br /&gt;
In this example we assume the id of the element that will contain the Cavern Status Widget is &amp;quot;widget&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1314</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1314"/>
		<updated>2011-10-18T19:42:44Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* jQuery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
** jsonp : Provides the output in JSON-P (Javascript Object Notation with Padding) format, intended for javascript/jQuery users. See the additional notes below on using this option.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== JSON-P ===&lt;br /&gt;
Setting the type argument in a request to &amp;quot;jsonp&amp;quot; will return output formatted for Javascript Object Notation with Padding, essentially an object of data passed to a callback function. This method is essential if you are trying to fetch the CAVCON data with javascript (due to the same-origin-policy applied by most browsers). To know more about JSONP, its usage and the reason of its existance read [http://en.wikipedia.org/wiki/JSONP Wikipedia's Article].&lt;br /&gt;
When using this option, it is also necessary to specify the function name of the callback procedure that will parse the returned array in the client, so a second argument, jsoncallback, must be supplied as in the following example:&lt;br /&gt;
:http://www.openuru.org/tools/cavstat.php?type=jsonp&amp;amp;jsoncallback=anyFunctionName&lt;br /&gt;
Note that the name of the callback function is not important as far as the server is concerned, but it '''must''' be supplied otherwise an error message will be returned.&lt;br /&gt;
&lt;br /&gt;
In response, the server will return data similar to the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
anyFunctionName({&amp;quot;LED&amp;quot;: &amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;, &lt;br /&gt;
&amp;quot;State&amp;quot;: &amp;quot;Open for exploration!&amp;quot;, &amp;quot;Link&amp;quot;: &amp;quot;Sign up to play at MystOnline.com!&amp;quot;, &lt;br /&gt;
&amp;quot;LinkURL&amp;quot;: &amp;quot;http://mystonline.com/play/&amp;quot;, &amp;quot;Message&amp;quot;: &amp;quot;Welcome to Myst Online: Uru Live! &lt;br /&gt;
Bug Chucker now available on Android Marketplace!&amp;quot;, &amp;quot;Origin&amp;quot;: &amp;quot;www.openuru.org&amp;quot;, &lt;br /&gt;
&amp;quot;OriginURL&amp;quot;: &amp;quot;http://www.openuru.org/&amp;quot;}) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarity, the array returned in the padded object consists of the following members:&lt;br /&gt;
* &amp;quot;LED&amp;quot;: A URL to the applicable colored status &amp;quot;lamp&amp;quot;; red green or yellow,&lt;br /&gt;
* &amp;quot;State&amp;quot;: Text string indicating the state of the cavern,&lt;br /&gt;
* &amp;quot;Link&amp;quot;: Text message intended to be used as anchor text for LinkURL,&lt;br /&gt;
* &amp;quot;LinkURL&amp;quot;: URL to the current MOULa sign-up/play page at mystonline.com,&lt;br /&gt;
* &amp;quot;Message&amp;quot;: The Cyan developer message, as shown on the MOULa startup dialogs,&lt;br /&gt;
* &amp;quot;Origin&amp;quot;: Text message intended to be used as anchor text for OriginURL.&lt;br /&gt;
* &amp;quot;OriginURL&amp;quot;: URL of the site that the status message has been delivered from.&lt;br /&gt;
There is no requirement that the end user implements all of these, or that they represent them in any particular manner giving the page designer complete freedom to manage the usage, format and layout as best suits their intended page layout.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
The following code can be used to dynamically update the cavern widget on a webpage.&lt;br /&gt;
&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'http://www.openuru.org/tools/cavstat.php',&lt;br /&gt;
    data: 'type=jsonp',&lt;br /&gt;
    dataType: 'jsonp',&lt;br /&gt;
    jsonp: 'jsoncallback',&lt;br /&gt;
    crossDomain: true,&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      output='&amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&amp;lt;img src=&amp;quot;'+data.LED+'&amp;quot;&amp;gt; '+data.State+'&amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt; - &amp;lt;a href=&amp;quot;'+data.LinkURL+'&amp;quot; target=&amp;quot;_blank&amp;quot;&amp;gt; '+data.Link+'&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; '+data.Message+' &amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;'+data.OriginURL+'&amp;quot;&amp;gt;'+data.Origin+'&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;';&lt;br /&gt;
      $(el).html(output);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In the code above you can see the ''output'' variable that contains the HTML code that will be generated in your web page, you can customize it to follow your website design or preferences. To know more about the member variables of the ''data'' object please consult the section ''JSONP'' above.&lt;br /&gt;
Optionally you can insert some error handling code in the error function, where we placed just a comment.&lt;br /&gt;
&lt;br /&gt;
Call the CavernStatus function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Call it every X seconds to make the widget update dynamically.&lt;br /&gt;
In this example we assume the id of the element that will contain the Cavern Status Widget is &amp;quot;widget&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1313</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1313"/>
		<updated>2011-10-18T19:30:12Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* JSON-P */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
** jsonp : Provides the output in JSON-P (Javascript Object Notation with Padding) format, intended for javascript/jQuery users. See the additional notes below on using this option.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== JSON-P ===&lt;br /&gt;
Setting the type argument in a request to &amp;quot;jsonp&amp;quot; will return output formatted for Javascript Object Notation with Padding, essentially an object of data passed to a callback function. This method is essential if you are trying to fetch the CAVCON data with javascript (due to the same-origin-policy applied by most browsers). To know more about JSONP, its usage and the reason of its existance read [http://en.wikipedia.org/wiki/JSONP Wikipedia's Article].&lt;br /&gt;
When using this option, it is also necessary to specify the function name of the callback procedure that will parse the returned array in the client, so a second argument, jsoncallback, must be supplied as in the following example:&lt;br /&gt;
:http://www.openuru.org/tools/cavstat.php?type=jsonp&amp;amp;jsoncallback=anyFunctionName&lt;br /&gt;
Note that the name of the callback function is not important as far as the server is concerned, but it '''must''' be supplied otherwise an error message will be returned.&lt;br /&gt;
&lt;br /&gt;
In response, the server will return data similar to the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
anyFunctionName({&amp;quot;LED&amp;quot;: &amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;, &lt;br /&gt;
&amp;quot;State&amp;quot;: &amp;quot;Open for exploration!&amp;quot;, &amp;quot;Link&amp;quot;: &amp;quot;Sign up to play at MystOnline.com!&amp;quot;, &lt;br /&gt;
&amp;quot;LinkURL&amp;quot;: &amp;quot;http://mystonline.com/play/&amp;quot;, &amp;quot;Message&amp;quot;: &amp;quot;Welcome to Myst Online: Uru Live! &lt;br /&gt;
Bug Chucker now available on Android Marketplace!&amp;quot;, &amp;quot;Origin&amp;quot;: &amp;quot;www.openuru.org&amp;quot;, &lt;br /&gt;
&amp;quot;OriginURL&amp;quot;: &amp;quot;http://www.openuru.org/&amp;quot;}) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarity, the array returned in the padded object consists of the following members:&lt;br /&gt;
* &amp;quot;LED&amp;quot;: A URL to the applicable colored status &amp;quot;lamp&amp;quot;; red green or yellow,&lt;br /&gt;
* &amp;quot;State&amp;quot;: Text string indicating the state of the cavern,&lt;br /&gt;
* &amp;quot;Link&amp;quot;: Text message intended to be used as anchor text for LinkURL,&lt;br /&gt;
* &amp;quot;LinkURL&amp;quot;: URL to the current MOULa sign-up/play page at mystonline.com,&lt;br /&gt;
* &amp;quot;Message&amp;quot;: The Cyan developer message, as shown on the MOULa startup dialogs,&lt;br /&gt;
* &amp;quot;Origin&amp;quot;: Text message intended to be used as anchor text for OriginURL.&lt;br /&gt;
* &amp;quot;OriginURL&amp;quot;: URL of the site that the status message has been delivered from.&lt;br /&gt;
There is no requirement that the end user implements all of these, or that they represent them in any particular manner giving the page designer complete freedom to manage the usage, format and layout as best suits their intended page layout.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
The following code can be used to dynamically update the cavern widget on a webpage. It cannot be used alone, it needs the PHP code above in a separate file.&lt;br /&gt;
&lt;br /&gt;
First set up a file with the PHP code above and at the end just do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
  echo getURL(&amp;quot;http://www.openuru.org/tools/cavstat.php?type=raw&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Save it as a separate file in your website. For the following part we will assume you placed the file in the root directory of your website with the name &amp;quot;cavern_status.php&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Then in your real page use the following javascript code.&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'/cavern_status.php',&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      $(el).html(data);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500,//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
    dataType: 'html',&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can insert manipulation of the HTML received from OpenUru and Error Handling where specified.&lt;br /&gt;
&lt;br /&gt;
Call this function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Call it every X seconds to make the widget update dynamically.&lt;br /&gt;
In this example we assume the id of the element that will contain the Cavern Status Widget is &amp;quot;widget&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately it is not possible to have a jQuery-only implementation of the Cavern Widget since most browsers don't allow webpages to request code from domains different than theirs.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1312</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1312"/>
		<updated>2011-10-18T19:29:03Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* JSON-P */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
** jsonp : Provides the output in JSON-P (Javascript Object Notation with Padding) format, intended for javascript/jQuery users. See the additional notes below on using this option.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== JSON-P ===&lt;br /&gt;
Setting the type argument in a request to &amp;quot;jsonp&amp;quot; will return output formatted for Javascript Object Notation with Padding, essentially an object of data passed to a callback function. This method is essential if you are trying to fetch the CAVCON data with javascript (due to the same-origin-policy applied by most browsers). To know more about JSONP, its usage and the reason of its existance read [http://en.wikipedia.org/wiki/JSONP Wikipedia's Article].&lt;br /&gt;
When using this option, it is also necessary to specify the function name of the callback procedure that will parse the returned array in the client, so a second argument, jsoncallback, must be supplied as in the following example:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
  http://www.openuru.org/tools/cavstat.php?type=jsonp&amp;amp;jsoncallback=anyFunctionName&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note that the name of the callback function is not important as far as the server is concerned, but it '''must''' be supplied otherwise an error message will be returned.&lt;br /&gt;
&lt;br /&gt;
In response, the server will return data similar to the following:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
anyFunctionName({&amp;quot;LED&amp;quot;: &amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;, &lt;br /&gt;
&amp;quot;State&amp;quot;: &amp;quot;Open for exploration!&amp;quot;, &amp;quot;Link&amp;quot;: &amp;quot;Sign up to play at MystOnline.com!&amp;quot;, &lt;br /&gt;
&amp;quot;LinkURL&amp;quot;: &amp;quot;http://mystonline.com/play/&amp;quot;, &amp;quot;Message&amp;quot;: &amp;quot;Welcome to Myst Online: Uru Live! &lt;br /&gt;
Bug Chucker now available on Android Marketplace!&amp;quot;, &amp;quot;Origin&amp;quot;: &amp;quot;www.openuru.org&amp;quot;, &lt;br /&gt;
&amp;quot;OriginURL&amp;quot;: &amp;quot;http://www.openuru.org/&amp;quot;}) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarity, the array returned in the padded object consists of the following members:&lt;br /&gt;
* &amp;quot;LED&amp;quot;: A URL to the applicable colored status &amp;quot;lamp&amp;quot;; red green or yellow,&lt;br /&gt;
* &amp;quot;State&amp;quot;: Text string indicating the state of the cavern,&lt;br /&gt;
* &amp;quot;Link&amp;quot;: Text message intended to be used as anchor text for LinkURL,&lt;br /&gt;
* &amp;quot;LinkURL&amp;quot;: URL to the current MOULa sign-up/play page at mystonline.com,&lt;br /&gt;
* &amp;quot;Message&amp;quot;: The Cyan developer message, as shown on the MOULa startup dialogs,&lt;br /&gt;
* &amp;quot;Origin&amp;quot;: Text message intended to be used as anchor text for OriginURL.&lt;br /&gt;
* &amp;quot;OriginURL&amp;quot;: URL of the site that the status message has been delivered from.&lt;br /&gt;
There is no requirement that the end user implements all of these, or that they represent them in any particular manner giving the page designer complete freedom to manage the usage, format and layout as best suits their intended page layout.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
The following code can be used to dynamically update the cavern widget on a webpage. It cannot be used alone, it needs the PHP code above in a separate file.&lt;br /&gt;
&lt;br /&gt;
First set up a file with the PHP code above and at the end just do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
  echo getURL(&amp;quot;http://www.openuru.org/tools/cavstat.php?type=raw&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Save it as a separate file in your website. For the following part we will assume you placed the file in the root directory of your website with the name &amp;quot;cavern_status.php&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Then in your real page use the following javascript code.&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'/cavern_status.php',&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      $(el).html(data);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500,//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
    dataType: 'html',&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can insert manipulation of the HTML received from OpenUru and Error Handling where specified.&lt;br /&gt;
&lt;br /&gt;
Call this function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Call it every X seconds to make the widget update dynamically.&lt;br /&gt;
In this example we assume the id of the element that will contain the Cavern Status Widget is &amp;quot;widget&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately it is not possible to have a jQuery-only implementation of the Cavern Widget since most browsers don't allow webpages to request code from domains different than theirs.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1307</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1307"/>
		<updated>2011-10-15T17:19:42Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* jQuery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
The following code can be used to dinamically update the cavern widget on a webpage. It cannot be used alone, it needs the PHP code above in a separate file.&lt;br /&gt;
&lt;br /&gt;
First set up a file with the PHP code above and at the end just do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
  echo getURL(&amp;quot;http://www.openuru.org/tools/cavstat.php?type=raw&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Save it as a separate file in your website. For the following part we will assume you placed the file in the root directory of your website with the name &amp;quot;cavern_status.php&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Then in your real page use the following javascript code.&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'/cavern_status.php',&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      $(el).html(data);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500,//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
    dataType: 'html',&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can insert manipulation of the HTML received from OpenUru and Error Handling where specified.&lt;br /&gt;
&lt;br /&gt;
Call this function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Call it every X seconds to make the widget update dinamically.&lt;br /&gt;
In this example we assume the id of the element that will contain the Cavern Status Widget is &amp;quot;widget&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately it is not possible to have a jQuery-only implementation of the Cavern Widget since most browsers don't allow webpages to request code from domains different than theirs.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1306</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1306"/>
		<updated>2011-10-15T17:17:42Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* jQuery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
The following code can be used to dinamically update the cavern widget on a webpage. It cannot be used alone, it needs the PHP code above in a separate file.&lt;br /&gt;
&lt;br /&gt;
First set up a file with the PHP code above and at the end just do:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
  echo getURL(&amp;quot;http://www.openuru.org/tools/cavstat.php?type=raw&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Save it as a separate file in your website. For the following part we will assume you placed the file in the root directory of your website with the name &amp;quot;cavern_status.php&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Then in your real page use the following javascript code.&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'/cavern_status.php',&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      $(el).html(data);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500,//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
    dataType: 'html',&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can insert manipulation of the HTML received from OpenUru and Error Handling where specified.&lt;br /&gt;
&lt;br /&gt;
Call this function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Optionally you can call it every X seconds to make the widget update dinamically.&lt;br /&gt;
In this example we assume the id of the element that will contain the Cavern Status Widget is &amp;quot;widget&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately it is not possible to have a jQuery-only implementation of the Cavern Widget since most browsers don't allow webpages to request code from domains different than theirs.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1305</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1305"/>
		<updated>2011-10-15T14:19:59Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* jQuery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
{{tba}}&lt;br /&gt;
This code doesn't work yet. Due to the &amp;quot;same-domain-policy&amp;quot; most browsers have.&lt;br /&gt;
&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'http://www.openuru.org/tools/cavstat.php',&lt;br /&gt;
    data: 'type=raw',&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      $(el).html(data);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500,//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
    dataType: 'html',&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can insert manipulation of the HTML received from OpenUru and Error Handling where specified.&lt;br /&gt;
&lt;br /&gt;
Call this function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Optionally you can call it every X seconds to make the widget update dinamically.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1304</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1304"/>
		<updated>2011-10-15T13:45:45Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* jQuery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'http://www.openuru.org/tools/cavstat.php',&lt;br /&gt;
    data: 'type=raw',&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      $(el).html(data);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500,//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
    dataType: 'html',&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can insert manipulation of the HTML received from OpenUru and Error Handling where specified.&lt;br /&gt;
&lt;br /&gt;
Call this function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Optionally you can call it every X seconds to make the widget update dinamically.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1303</id>
		<title>Cavern Status Widget</title>
		<link rel="alternate" type="text/html" href="https://wiki.openuru.org/index.php?title=Cavern_Status_Widget&amp;diff=1303"/>
		<updated>2011-10-15T13:45:22Z</updated>

		<summary type="html">&lt;p&gt;Leonardo: /* JQuery */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a simple widget that you can use in webpages to display the current status of the MOULagain servers.&lt;br /&gt;
&lt;br /&gt;
{{draft}}&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&lt;br /&gt;
During the development of the styling for the OpenUru.org website, it was felt that offering an indication of whether the MOULa cavern was open or not could be a useful feature. This already (partly) existed in the Cyan MOULa client launcher, in the form of the &amp;quot;welcome&amp;quot; message displayed during startup. By &amp;quot;piggybacking&amp;quot; on the source of that message, and after negotiating with Cyan on a standard for flags within the messages, it became possible to provide green, yellow or red status lights:&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-green.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Open. Logins are unrestricted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-yellow.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Restrictions. The cavern is open but some restrictions are in place, e.g. there is downtime scheduled to occur shortly.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;div style=&amp;quot;float: left&amp;quot;&amp;gt;http://assets.openuru.org/wiki/img/led-red.gif&amp;lt;/div&amp;gt;&amp;amp;nbsp; - Closed. No user logins are permitted.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A link back to the &amp;quot;Play&amp;quot; page at mystonline.com was included in the displayed status to help support Cyan Worlds, as well as the entirety of the status message, which may at times include promotional messages for other Cyan products.&lt;br /&gt;
&lt;br /&gt;
In response to enquiries following the announcement of this feature, a widget was split out from the site styling to allow others to include this in their own webpages. The widget can be made to display in various forms and styles using the control options described in the [[#Usage|Usage section]]. Some examples are given in the following images:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat1.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Full Cavern Status with border line added'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat2.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Minimised Cavern Status'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;http://assets.openuru.org/wiki/cavstat/cavstat3.png&amp;lt;br&amp;gt;&lt;br /&gt;
'''Cavern Status with alternative colors'''&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
The simplest way to use the Cavern Status Widget is by inserting an iframe in your webpage at the point you'd like the widget to appear:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The width and height settings in the iframe determine the size of the space allowed in your page for the status message. If the message box can't be fitted inside that space, then scroll bars may appear. Setting &amp;lt;code&amp;gt;frameborder = &amp;quot;0&amp;quot;&amp;lt;/code&amp;gt; hides the rather ugly boundary that would otherwise be shown.&lt;br /&gt;
&lt;br /&gt;
To avoid using an iframe or have more control over presentation, see [[#Advanced_topics|Advanced topics]].&lt;br /&gt;
&lt;br /&gt;
=== Usage Notes ===&lt;br /&gt;
Recent updates to the code behind the widget introduced local caching of the status message that is fetched from Cyan's support server. This has a number of effects:&lt;br /&gt;
# Page display is faster since there no longer is a need to wait on an additional GET each time the status message is displayed.&lt;br /&gt;
# Page load will not &amp;quot;hang&amp;quot; for an extended time if the Cyan support server is offline.&lt;br /&gt;
# Loading on the Cyan support server is limited and flattened out.&lt;br /&gt;
# The displayed state of the Cavern may &amp;quot;lag&amp;quot; the true state by up to one minute (the cache refresh interval).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
Please remember that the Cavern Status display is not dynamic: It will ''only'' update if you refresh or reload the page you are viewing. There is no universally easy way to have the server &amp;quot;push&amp;quot; a real-time update to your browser.&lt;br /&gt;
&lt;br /&gt;
==Controlling the appearance==&lt;br /&gt;
You can control the appearance of the status message so that it blends better with your webpage: Add a '?' after the call to cavstat.php then list the parameter=value pairs, separating each with '&amp;amp;' and making sure to avoid leaving any spaces. The possible parameters are:&lt;br /&gt;
* '''color=''' The color of the text as a hex value, omitting the usual leading '#' symbol. Defaults to black if parameter omitted.&lt;br /&gt;
&lt;br /&gt;
* '''bgcolor=''' The background color of the box containing the status message, as a hex value, omitting the usual leading '#' symbol. Defaults to grey (DDDDDD) if parameter omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''txtsize=''' The size of the body text of the message, e.g. 12pt, 14px, 1.1em. Defaults to 1.0em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''hdsize=''' The size of the heading text of the message, e.g. 12pt, 14px, 1.1em. The headings are bold, so you may want to reduce the size compared to the main text to restore some &amp;quot;balance&amp;quot;. Defaults to 0.8em if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''width=''' The width of the box containing the status message, in px or %. Note that the iframe may also have a width specified and you may need to adjust both get a satisfactory result. Defaults to 500px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''height=''' The height of the box containing the status message, in px or %. Note that the iframe may also have a height specified and you may need to adjust both get a satisfactory result. Defaults to 60px if parameter is omitted.&lt;br /&gt;
 &lt;br /&gt;
* '''border=''' The color of the border around the box containing the status message, as a hex value, omitting the usual leading '#' symbol. The border is a 1px solid line and is only displayed if a value is specified, otherwise the box will be borderless (default).&lt;br /&gt;
&lt;br /&gt;
* '''type=''' Controls the display and styling type:&lt;br /&gt;
** maxi : The default display - shows the cavern status indication and a link to Cyan's &amp;quot;Play&amp;quot; page on the first line, and the Cyan &amp;quot;Developer's message&amp;quot; on the second line.&lt;br /&gt;
** midi : Single line display, with only the cavern status and the &amp;quot;Play&amp;quot; link.&lt;br /&gt;
** mini : Single line display, with only the cavern status included.&lt;br /&gt;
** raw : Most inline styling is removed and all other parameters are ignored. Used when applying local styling in more advanced uses (see below).&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;iframe src=&amp;quot;http://www.openuru.org/tools/cavstat.php?bgcolor=ffdddd&amp;amp;hdsize=0.9em&amp;amp;border=000099&amp;quot; width=&amp;quot;550px&amp;quot; height=&amp;quot;120px&amp;quot; frameborder=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;p&amp;gt;Your browser does not support iframes.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Advanced topics==&lt;br /&gt;
=== PHP ===&lt;br /&gt;
If your page is written in PHP, you could use the [http://www.php.net/manual/en/book.curl.php cURL library] to fetch the widget output and build it into your page. This would allow you to use the IDs and classes along with your own page CSS to apply styling. For this, you need to ensure that all unwanted inline styling is removed from the widget by using the &amp;lt;code&amp;gt;?type=raw&amp;lt;/code&amp;gt; control.&lt;br /&gt;
&lt;br /&gt;
This will produce a code fragment that looks similar to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;cspanel&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Cavern Status:&amp;lt;/span&amp;gt;&lt;br /&gt;
    &amp;lt;img src=&amp;quot;http://www.openuru.org/sitestyle/img/led-green.gif&amp;quot;&amp;gt; Open for exploration! &lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_link&amp;quot;&amp;gt;&lt;br /&gt;
      - &amp;lt;a href=&amp;quot;http://mystonline.com/play/&amp;quot;&amp;gt; Sign up to play at MystOnline.com!&amp;lt;/a&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;cavstat_row2&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;span class=&amp;quot;cshead&amp;quot;&amp;gt;Developer Message:&amp;lt;/span&amp;gt; Welcome to Myst Online: Uru Live!&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div style=&amp;quot;font-size: 8px; text-align: right;&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.openuru.org/&amp;quot;&amp;gt;www.openuru.org&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Include the following functions in your PHP:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  // Check availability of site&lt;br /&gt;
  function isURLOnline($sSiteToCheck)&lt;br /&gt;
  {&lt;br /&gt;
  	if(phpversion() &amp;gt; &amp;quot;5.2&amp;quot;)&lt;br /&gt;
    {&lt;br /&gt;
      if(function_exists('get_headers')==True &amp;amp;&amp;amp; ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        $sIUOTemp = @get_headers($sSiteToCheck);&lt;br /&gt;
        if($sIUOTemp == '')&lt;br /&gt;
        {&lt;br /&gt;
          return True; // Assume it's online even when nothing is returned&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
          if(strpos($sIUOTemp[0], '200') == true)&lt;br /&gt;
          {&lt;br /&gt;
            return True;&lt;br /&gt;
          }&lt;br /&gt;
          else&lt;br /&gt;
          {&lt;br /&gt;
            return False;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        return True; // Assume true if we can't check it .......&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      return True; // get_headers apparently isn't available in PHP4&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // Gets a URL's content&lt;br /&gt;
  function getURL($sURL)&lt;br /&gt;
  {&lt;br /&gt;
    if(isURLOnline($sURL) == false)&lt;br /&gt;
    {&lt;br /&gt;
      $sURLTemp = 'Unable to connect to server';&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if(@function_exists('file_get_contents') &amp;amp;&amp;amp; @ini_get('allow_url_fopen') == true)&lt;br /&gt;
      {&lt;br /&gt;
        // Use file_get_contents&lt;br /&gt;
        $sURLTemp = @file_get_contents($sURL);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // Use cURL (if available)&lt;br /&gt;
        $curl = @curl_init();&lt;br /&gt;
        curl_setopt($curl, CURLOPT_URL, $sURL);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_VERBOSE, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_HEADER, 0);&lt;br /&gt;
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);&lt;br /&gt;
        $sURLTemp = @curl_exec($curl);&lt;br /&gt;
        @curl_close($curl);&lt;br /&gt;
      }&lt;br /&gt;
      return $sURLTemp;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fetch the code fragment using a line similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  $cavernStatus=getURL(&amp;quot;&amp;lt;nowiki&amp;gt;http://www.openuru.org/tools/cavstat.php?type=raw&amp;lt;/nowiki&amp;gt;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will give you the entire fragment in a string, $cavernStatus, that you can then echo to your own page or manipulate as you wish.&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
Include the following code in the scripts of your webpage. The code assumes you are not using the &amp;quot;No Conflict&amp;quot; option of jQuery. If you are using it, change all the calls to &amp;quot;$&amp;quot; with calls to &amp;quot;jQuery&amp;quot;.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;jquery&amp;quot;&amp;gt;&lt;br /&gt;
function CavernStatus(el){&lt;br /&gt;
  $.ajax({&lt;br /&gt;
    type:'GET',&lt;br /&gt;
    url:'http://www.openuru.org/tools/cavstat.php',&lt;br /&gt;
    data: 'type=raw',&lt;br /&gt;
    success: function(data){&lt;br /&gt;
      //In this point, if you want, you can manipulate the HTML elements received from OpenUru&lt;br /&gt;
      $(el).html(data);&lt;br /&gt;
    },&lt;br /&gt;
    error: function(jqXHR, textStatus, errorThrown){//What to do if error happens&lt;br /&gt;
      //You can choose to let the user know the request didn't succeed&lt;br /&gt;
    },&lt;br /&gt;
    timeout: 1500,//Script timesout in 1.5 seconds if server doesn't respond&lt;br /&gt;
    dataType: 'html',&lt;br /&gt;
  })&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can insert manipulation of the HTML received from OpenUru and Error Handling where specified.&lt;br /&gt;
&lt;br /&gt;
Call this function somewhere in your code (usually when document is ready, with $.ready()), passing the jQuery selector for the element where you want to put the widget. Optionally you can call it every X seconds to make the widget update dinamically.&lt;br /&gt;
&lt;br /&gt;
====Example:====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
$(function(){//Short version of $.ready()&lt;br /&gt;
  CavernStatus('#widget')//Initial Loading&lt;br /&gt;
  setInterval(&amp;quot;CavernStatus('#widget')&amp;quot;,600000)//Update the widget every 10 minutes.&lt;br /&gt;
})&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:OpenUru.org]]&lt;/div&gt;</summary>
		<author><name>Leonardo</name></author>
	</entry>
</feed>