Compare commits
No commits in common. 'develop' and 'master' have entirely different histories.
@ -1,2 +0,0 @@
|
||||
config.php
|
||||
config.mysql.php
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,319 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
cphp_dependency_provides("cphp_formbuilder", "1.0");
|
||||
|
||||
$cphp_formbuilder_increment = 0;
|
||||
|
||||
abstract class CPHPFormBuilderBaseClass
|
||||
{
|
||||
public $parameters = array();
|
||||
|
||||
public function AddParameter($key, $value)
|
||||
{
|
||||
$this->parameters[$key] = $value;
|
||||
}
|
||||
|
||||
public function RenderParameters($parameters)
|
||||
{
|
||||
if(empty($parameters))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
$rendered = array();
|
||||
|
||||
foreach($parameters as $key => $value)
|
||||
{
|
||||
$value = utf8entities($value);
|
||||
$rendered[] = "{$key}=\"{$value}\"";
|
||||
}
|
||||
|
||||
return " " . implode(" ", $rendered);
|
||||
}
|
||||
|
||||
public function RenderNote()
|
||||
{
|
||||
if(!empty($this->note))
|
||||
{
|
||||
return "<div class=\"cphp_fbd_note\">{$this->note}</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CPHPFormBuilderContainer extends CPHPFormBuilderBaseClass
|
||||
{
|
||||
public $elements = array();
|
||||
|
||||
public function AddElement($element)
|
||||
{
|
||||
$this->elements[] = $element;
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormBuilder extends CPHPFormBuilderContainer
|
||||
{
|
||||
public $method = "";
|
||||
public $action = "";
|
||||
|
||||
public function __construct($method, $target)
|
||||
{
|
||||
$this->method = strtolower($method);
|
||||
$this->action = $target;
|
||||
}
|
||||
|
||||
public function Render()
|
||||
{
|
||||
$rendered_elements = "";
|
||||
|
||||
foreach($this->elements as $element)
|
||||
{
|
||||
$rendered_elements .= $element->Render();
|
||||
}
|
||||
|
||||
$this->AddParameter("method", $this->method);
|
||||
$this->AddParameter("action", $this->action);
|
||||
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
|
||||
return "<form{$rendered_parameters}>{$rendered_elements}</form>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormSection extends CPHPFormBuilderContainer
|
||||
{
|
||||
public $label = "";
|
||||
public $fieldset = true;
|
||||
public $classname = "";
|
||||
|
||||
public function __construct($fieldset = true, $label = "")
|
||||
{
|
||||
if(!empty($label))
|
||||
{
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
$this->fieldset = $fieldset;
|
||||
}
|
||||
|
||||
public function Render()
|
||||
{
|
||||
if(!empty($this->label))
|
||||
{
|
||||
$legend = "<legend>{$this->label}</legend>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$legend = "";
|
||||
}
|
||||
|
||||
if($this->fieldset === true)
|
||||
{
|
||||
$this->classname = trim("{$this->classname} cphp_fbd_fieldset");
|
||||
}
|
||||
|
||||
$rendered_elements = "";
|
||||
|
||||
foreach($this->elements as $element)
|
||||
{
|
||||
$rendered_elements .= $element->Render();
|
||||
}
|
||||
|
||||
if($this->fieldset === true)
|
||||
{
|
||||
$this->AddParameter("class", $this->classname);
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
return "<fieldset{$rendered_parameters}>{$legend}<div class=\"cphp_fbd_form\">{$rendered_elements}</div></fieldset>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<div class=\"cphp_fbd_form\"{$rendered_parameters}>{$rendered_elements}</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CPHPFormInputElement extends CPHPFormBuilderBaseClass
|
||||
{
|
||||
public $id = "";
|
||||
public $name = "";
|
||||
public $value = "";
|
||||
public $label = "";
|
||||
|
||||
public function __construct($label, $name, $value = "", $note = "", $id = "")
|
||||
{
|
||||
global $cphp_formbuilder_increment;
|
||||
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
$this->label = $label;
|
||||
$this->note = $note;
|
||||
|
||||
if(empty($id))
|
||||
{
|
||||
$this->id = "cphp_fbd_{$cphp_formbuilder_increment}";
|
||||
$cphp_formbuilder_increment += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class CPHPFormInput extends CPHPFormInputElement
|
||||
{
|
||||
public function Render()
|
||||
{
|
||||
$this->AddParameter("id", $this->id);
|
||||
$this->AddParameter("type", $this->type);
|
||||
$this->AddParameter("name", $this->name);
|
||||
$this->AddParameter("value", $this->value);
|
||||
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
$rendered_note = $this->RenderNote();
|
||||
|
||||
return "<div class=\"cphp_fbd_row\"><div class=\"cphp_fbd_label\">{$this->label}{$rendered_note}</div><div class=\"cphp_fbd_field\"><input{$rendered_parameters}></div></div>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormTextInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "text";
|
||||
}
|
||||
|
||||
class CPHPFormPasswordInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "password";
|
||||
}
|
||||
|
||||
class CPHPFormDateInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "date";
|
||||
}
|
||||
|
||||
class CPHPFormTimeInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "time";
|
||||
}
|
||||
|
||||
class CPHPFormEmailInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "email";
|
||||
}
|
||||
|
||||
class CPHPFormUrlInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "url";
|
||||
}
|
||||
|
||||
class CPHPFormRangeInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "range";
|
||||
}
|
||||
|
||||
class CPHPFormColorInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "color";
|
||||
}
|
||||
|
||||
class CPHPFormSearchInput extends CPHPFormInput
|
||||
{
|
||||
public $type = "search";
|
||||
}
|
||||
|
||||
class CPHPFormCheckboxGroup extends CPHPFormBuilderContainer
|
||||
{
|
||||
public function __construct($label, $note = "")
|
||||
{
|
||||
global $cphp_formbuilder_increment;
|
||||
|
||||
$this->label = $label;
|
||||
$this->note = $note;
|
||||
}
|
||||
|
||||
public function Render()
|
||||
{
|
||||
$rendered_note = $this->RenderNote();
|
||||
|
||||
$rendered_elements = "";
|
||||
|
||||
foreach($this->elements as $element)
|
||||
{
|
||||
$rendered_elements .= $element->Render();
|
||||
}
|
||||
|
||||
return "<div class=\"cphp_fbd_row\"><div class=\"cphp_fbd_label\">{$this->label}{$rendered_note}</div><div class=\"cphp_fbd_field\">{$rendered_elements}</div></div>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormCheckbox extends CPHPFormInputElement
|
||||
{
|
||||
|
||||
public function Render()
|
||||
{
|
||||
$this->AddParameter("id", $this->id);
|
||||
$this->AddParameter("type", "checkbox");
|
||||
$this->AddParameter("name", $this->name);
|
||||
|
||||
if($this->value === true)
|
||||
{
|
||||
$this->AddParameter("checked", "");
|
||||
}
|
||||
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
$rendered_note = $this->RenderNote();
|
||||
return "<div class=\"cphp_fbd_cblabel\"><input{$rendered_parameters}><label for=\"{$this->id}\">{$this->label}{$rendered_note}</label></div>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormRadioButton extends CPHPFormInput
|
||||
{
|
||||
public $type = "radio";
|
||||
}
|
||||
|
||||
class CPHPFormButton extends CPHPFormInputElement
|
||||
{
|
||||
public $type = "button";
|
||||
|
||||
public function Render()
|
||||
{
|
||||
$this->AddParameter("type", $this->type);
|
||||
$this->AddParameter("name", $this->name);
|
||||
$this->AddParameter("value", $this->value);
|
||||
|
||||
$rendered_parameters = $this->RenderParameters($this->parameters);
|
||||
|
||||
return "<div class=\"cphp_fbd_row\"><div class=\"cphp_fbd_label\"></div><div class=\"cphp_fbd_field\"><button{$rendered_parameters}>{$this->label}</button></div></div>";
|
||||
}
|
||||
}
|
||||
|
||||
class CPHPFormSubmitButton extends CPHPFormButton
|
||||
{
|
||||
public $type = "submit";
|
||||
}
|
||||
|
||||
class CPHPFormResetButton extends CPHPFormButton
|
||||
{
|
||||
public $type = "reset";
|
||||
}
|
||||
|
||||
class CPHPFormSelect extends CPHPFormInputElement
|
||||
{
|
||||
public $options = array();
|
||||
}
|
||||
?>
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
$cphp_class_map = array(
|
||||
'classa' => "ClassA",
|
||||
'classb' => "ClassB"
|
||||
);
|
||||
|
||||
$cphp_locale_name = "english";
|
||||
$cphp_locale_path = "locales";
|
||||
$cphp_locale_ext = "lng";
|
||||
|
||||
$cphp_usersettings[CPHP_SETTING_TIMEZONE] = "Europe/Amsterdam";
|
||||
|
||||
/* These are the memcache settings. You will need to have memcache set
|
||||
* up on your server to use these. Compression requires zlib. */
|
||||
$cphp_memcache_enabled = true; // Whether to user memcache.
|
||||
$cphp_memcache_server = "localhost"; // The hostname of the memcached
|
||||
$cphp_memcache_port = 11211; // The port number of memcached
|
||||
$cphp_memcache_compressed = true; // Whether to compress memcache objects
|
||||
|
||||
$cphp_mysql_enabled = true;
|
||||
|
||||
require("config.mysql.php");
|
||||
|
||||
$cphp_components = array(
|
||||
"router",
|
||||
"errorhandler",
|
||||
"formbuilder"
|
||||
);
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
if(empty($_CPHP_CONFIG))
|
||||
{
|
||||
die("No valid CPHP configuration path was specified. Refer to the CPHP manual for instructions.");
|
||||
}
|
||||
|
||||
$confdata = @file_get_contents($_CPHP_CONFIG);
|
||||
|
||||
if($confdata === false)
|
||||
{
|
||||
die("The specified CPHP configuration path was not found. Refer to the CPHP manual for instructions.");
|
||||
}
|
||||
|
||||
$cphp_config = @json_decode($confdata);
|
||||
|
||||
if(json_last_error() != JSON_ERROR_NONE)
|
||||
{
|
||||
die("Failed to parse CPHP configuration. Refer to the CPHP manual for instructions.");
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
class CSRF
|
||||
{
|
||||
public static function GenerateToken()
|
||||
{
|
||||
$key = random_string(12);
|
||||
$token = random_string(25);
|
||||
|
||||
if(!isset($_SESSION['_CPHP_CSRF_KEYS']))
|
||||
{
|
||||
$_SESSION['_CPHP_CSRF_KEYS'] = array();
|
||||
}
|
||||
|
||||
$_SESSION['_CPHP_CSRF_KEYS'][$key] = $token;
|
||||
|
||||
return array(
|
||||
'key' => $key,
|
||||
'token' => $token
|
||||
);
|
||||
}
|
||||
|
||||
public static function GenerateReplacement($matches)
|
||||
{
|
||||
$pair = CSRF::GenerateToken();
|
||||
|
||||
return $matches[0] . "
|
||||
<input name=\"_CPHP_CSRF_KEY\" type=\"hidden\" value=\"{$pair['key']}\">
|
||||
<input name=\"_CPHP_CSRF_TOKEN\" type=\"hidden\" value=\"{$pair['token']}\">";
|
||||
}
|
||||
|
||||
public static function InsertTokens($input)
|
||||
{
|
||||
return preg_replace_callback("/<form[^>]*>(?!\s*<input name=\"_CPHP_CSRF)/i", "CSRF::GenerateReplacement", $input);
|
||||
}
|
||||
|
||||
public static function VerifyToken()
|
||||
{
|
||||
if(!empty($_POST['_CPHP_CSRF_KEY']) && !empty($_POST['_CPHP_CSRF_TOKEN']))
|
||||
{
|
||||
$key = $_POST['_CPHP_CSRF_KEY'];
|
||||
$token = $_POST['_CPHP_CSRF_TOKEN'];
|
||||
|
||||
if(empty($_SESSION['_CPHP_CSRF_KEYS'][$key]) || $_SESSION['_CPHP_CSRF_KEYS'][$key] != $token)
|
||||
{
|
||||
throw new CsrfException("The given CSRF token does not match the given CSRF key.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new CsrfException("No CSRF token present in submitted data.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CsrfException extends Exception {}
|
@ -1,388 +0,0 @@
|
||||
<?php
|
||||
|
||||
$cphp_debug_start = microtime(true);
|
||||
$cphp_debug_log = array();
|
||||
$cphp_debug_enabled = false;
|
||||
|
||||
function cphp_debug_enable()
|
||||
{
|
||||
global $cphp_debug_enabled;
|
||||
|
||||
$cphp_debug_enabled = true;
|
||||
}
|
||||
|
||||
function cphp_debug_disable()
|
||||
{
|
||||
global $cphp_debug_enabled;
|
||||
|
||||
$cphp_debug_enabled = false;
|
||||
}
|
||||
|
||||
function cphp_debug_snapshot($data)
|
||||
{
|
||||
global $cphp_debug_start, $cphp_debug_log, $cphp_debug_enabled;
|
||||
|
||||
if($cphp_debug_enabled === true)
|
||||
{
|
||||
$timestamp = microtime(true) - $cphp_debug_start;
|
||||
|
||||
$cphp_debug_log[] = array(
|
||||
'timestamp' => $timestamp,
|
||||
'data' => $data
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function cphp_debug_dump()
|
||||
{
|
||||
global $cphp_debug_log;
|
||||
|
||||
return json_encode($cphp_debug_log);
|
||||
}
|
||||
|
||||
function cphp_debug_display($data)
|
||||
{
|
||||
/* We can't use the templater for this, because that would make this function unusable if the
|
||||
* templater itself were to ever be the subject of the debugging. */
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CPHP Debuglog Viewer</title>
|
||||
<style>
|
||||
body
|
||||
{
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#slider
|
||||
{
|
||||
background-color: #DDDDDD;
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
height: 100px;
|
||||
user-select: none;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
}
|
||||
|
||||
#slider_bar
|
||||
{
|
||||
background-color: #C8C8C8;
|
||||
height: 24px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#slider_handle
|
||||
{
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
background-color: #6F6F6F;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#slider_handle.dragging
|
||||
{
|
||||
background-color: #000000;
|
||||
}
|
||||
|
||||
#datapoint_info
|
||||
{
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
#details
|
||||
{
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
top: 100px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.variable
|
||||
{
|
||||
padding-left: 48px;
|
||||
border-top: 1px solid silver;
|
||||
}
|
||||
|
||||
.variable .name
|
||||
{
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.variable .data
|
||||
{
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
a.expander
|
||||
{
|
||||
text-decoration: none;
|
||||
color: blue;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.data.undefined
|
||||
{
|
||||
color: silver;
|
||||
}
|
||||
|
||||
.data.text
|
||||
{
|
||||
color: #A000B2;
|
||||
}
|
||||
|
||||
.data.numeric
|
||||
{
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
||||
<script>
|
||||
var data_points = <?php echo($data); ?>;
|
||||
|
||||
var total_data_points = data_points.length;
|
||||
|
||||
var current_point = 0;
|
||||
|
||||
function sliderUpdate()
|
||||
{
|
||||
total_width = $('#slider_bar').width() - $('#slider_handle').width();
|
||||
current_position = $('#slider_handle').offset().left;
|
||||
|
||||
point_width = total_width / (total_data_points - 1);
|
||||
closest_data_point = Math.round(current_position / point_width);
|
||||
current_point = closest_data_point;
|
||||
|
||||
real_position = closest_data_point * point_width;
|
||||
$('#slider_handle').css({'left': real_position});
|
||||
|
||||
relevant_data_point = data_points[closest_data_point];
|
||||
|
||||
$('#datapoint_info').html("<strong>Data point:</strong> " + closest_data_point + "<br><strong>Timestamp:</strong> " + relevant_data_point['timestamp'])
|
||||
|
||||
updateTree(relevant_data_point['data']);
|
||||
}
|
||||
|
||||
function switchDataPoint(i)
|
||||
{
|
||||
total_width = $('#slider_bar').width() - $('#slider_handle').width();
|
||||
point_width = total_width / (total_data_points - 2);
|
||||
real_position = i * point_width;
|
||||
$('#slider_handle').css({'left': real_position});
|
||||
|
||||
current_point = i;
|
||||
|
||||
$('#datapoint_info').html("<strong>Data point:</strong> " + i + "<br><strong>Timestamp:</strong> " + data_points[i]['timestamp'])
|
||||
|
||||
updateTree(data_points[i]['data']);
|
||||
}
|
||||
|
||||
function updateTree(data)
|
||||
{
|
||||
$('.variable.array').children('.variable').remove();
|
||||
$('.data.text, .data.numeric').html("undefined").addClass("undefined").removeClass("text").removeClass("numeric");
|
||||
updateElements(data, "root", "item");
|
||||
|
||||
$('a.expander').each(function(){
|
||||
if($(this).text() == "[+]")
|
||||
{
|
||||
$(this).parent().children('.variable').hide();
|
||||
}
|
||||
});
|
||||
|
||||
hookExpanders();
|
||||
}
|
||||
|
||||
function initializeElements()
|
||||
{
|
||||
/* Build a prototype for display, out of all the available datapoints. */
|
||||
prototype = {};
|
||||
|
||||
for(x in data_points)
|
||||
{
|
||||
prototype = $.extend(true, prototype, data_points[x]);
|
||||
}
|
||||
|
||||
createElements(prototype['data'], "root", "item").appendTo('#details');
|
||||
}
|
||||
|
||||
function createElements(source, key, hierarchy)
|
||||
{
|
||||
var item;
|
||||
var id = hierarchy + "_" + key.replace(/[^a-z0-9_]/gi,'');
|
||||
|
||||
if($.isArray(source))
|
||||
{
|
||||
/* Array. */
|
||||
var me = $('<div class="variable array" id="' + id + '"><a class="expander" href="javascript:void(0);">[-]</a><span class="name">' + key + '</span><span class="data undefined">Array</span></div>');
|
||||
}
|
||||
else if($.isPlainObject(source))
|
||||
{
|
||||
/* Object. */
|
||||
var me = $('<div class="variable object" id="' + id + '"><a class="expander" href="javascript:void(0);">[-]</a><span class="name">' + key + '</span><span class="data undefined">Object</span></div>');
|
||||
|
||||
for(item in source)
|
||||
{
|
||||
me.append(createElements(source[item], item, id));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Value. */
|
||||
var me = $('<div class="variable value" id="' + id + '"><span class="name">' + key + '</span><span class="data undefined">undefined</span></div>');
|
||||
}
|
||||
|
||||
return me;
|
||||
}
|
||||
|
||||
function updateElements(source, key, hierarchy)
|
||||
{
|
||||
var item;
|
||||
var id = hierarchy + "_" + key.replace(/[^a-z0-9_]/gi,'');
|
||||
|
||||
if($.isArray(source))
|
||||
{
|
||||
/* Array. */
|
||||
//$('#' + id).children('.variable').remove();
|
||||
|
||||
for(item in source)
|
||||
{
|
||||
$('#' + id).append(createElements(source[item], item, id));
|
||||
updateElements(source[item], item, id);
|
||||
}
|
||||
}
|
||||
else if($.isPlainObject(source))
|
||||
{
|
||||
/* Object. */
|
||||
|
||||
for(item in source)
|
||||
{
|
||||
updateElements(source[item], item, id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Value. */
|
||||
var target = $('#' + id).children('.data');
|
||||
|
||||
target.html(source);
|
||||
target.removeClass("undefined");
|
||||
|
||||
if(typeof(source) == "number")
|
||||
{
|
||||
target.addClass("numeric");
|
||||
}
|
||||
else
|
||||
{
|
||||
target.addClass("text");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function hookExpanders()
|
||||
{
|
||||
$('a.expander').click(function(){
|
||||
if($(this).text() == "[-]")
|
||||
{
|
||||
/* Collapse */
|
||||
$(this).text("[+]");
|
||||
$(this).parent().children(".variable").hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Expand */
|
||||
$(this).text("[-]");
|
||||
$(this).parent().children(".variable").show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function(){
|
||||
var drag_start_x = 0;
|
||||
var drag_start_y = 0;
|
||||
var dragging_slider = false;
|
||||
|
||||
$('#slider_handle').mousedown(function(e){
|
||||
dragging_slider = true;
|
||||
parent_offset = $(this).offset();
|
||||
drag_start_x = e.pageX - parent_offset.left;
|
||||
$('#slider_handle').addClass("dragging");
|
||||
});
|
||||
|
||||
$('body').mouseup(function(e){
|
||||
if(dragging_slider == true)
|
||||
{
|
||||
dragging_slider = false;
|
||||
$('#slider_handle').removeClass("dragging");
|
||||
}
|
||||
});
|
||||
|
||||
$('body').mousemove(function(e){
|
||||
//$('#details').html("Dragging: "+dragging_slider+", drag_start_x: "+drag_start_x+", pageX: "+e.pageX);
|
||||
if(dragging_slider == true)
|
||||
{
|
||||
newpos = e.pageX - drag_start_x;
|
||||
|
||||
if(newpos > 0 && newpos < (total_width))
|
||||
{
|
||||
$('#slider_handle').css({'left': newpos});
|
||||
}
|
||||
else if(newpos < 0)
|
||||
{
|
||||
$('#slider_handle').css({'left': 0});
|
||||
}
|
||||
else if(newpos > (total_width))
|
||||
{
|
||||
$('#slider_handle').css({'left': total_width});
|
||||
}
|
||||
|
||||
sliderUpdate();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).keydown(function(e){
|
||||
if(e.keyCode == 37 && current_point > 0)
|
||||
{
|
||||
switchDataPoint(current_point - 1);
|
||||
}
|
||||
else if(e.keyCode == 39 && current_point < total_data_points - 2)
|
||||
{
|
||||
switchDataPoint(current_point + 1);
|
||||
}
|
||||
});
|
||||
|
||||
var total_width = $('#slider_bar').width() - $('#slider_handle').width();
|
||||
|
||||
initializeElements();
|
||||
sliderUpdate();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="slider">
|
||||
<div id="slider_bar">
|
||||
<div id="slider_handle"></div>
|
||||
</div>
|
||||
<div id="datapoint_info">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="details">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* CPHP is more free software. It is licensed under the WTFPL, which
|
||||
* allows you to do pretty much anything with it, without having to
|
||||
* ask permission. Commercial use is allowed, and no attribution is
|
||||
* required. We do politely request that you share your modifications
|
||||
* to benefit other developers, but you are under no enforced
|
||||
* obligation to do so :)
|
||||
*
|
||||
* Please read the accompanying LICENSE document for the full WTFPL
|
||||
* licensing text.
|
||||
*/
|
||||
|
||||
if($_CPHP !== true) { die(); }
|
||||
|
||||
if(!isset($cphp_config->libraries))
|
||||
{
|
||||
/* No library configuration has been specified. We don't need to
|
||||
* execute the rest of this file. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Some libraries want to have a cache directory. Instead of storing all
|
||||
* this stuff in the document root, we'll put it into /tmp (or any other
|
||||
* config-specified directory). We should probably make sure the needed
|
||||
* directories exist, though... */
|
||||
|
||||
$tmp_dir = (isset($cphp_config->tmp_dir)) ? $cphp_config->tmp_dir : "/tmp";
|
||||
|
||||
if(!file_exists("{$tmp_dir}/cphp"))
|
||||
{
|
||||
mkdir("{$tmp_dir}/cphp", 0700);
|
||||
}
|
||||
|
||||
if(!file_exists("{$tmp_dir}/cphp/cache"))
|
||||
{
|
||||
mkdir("{$tmp_dir}/cphp/cache", 0700);
|
||||
}
|
||||
|
||||
/* We'll set up HTMLPurifier here if so desired. */
|
||||
if(isset($cphp_config->libraries->htmlpurifier))
|
||||
{
|
||||
if(!is_dir("{$tmp_dir}/cphp/cache/htmlpurifier"))
|
||||
{
|
||||
mkdir("{$tmp_dir}/cphp/cache/htmlpurifier", 0700);
|
||||
}
|
||||
|
||||
$library_config = $cphp_config->libraries->htmlpurifier;
|
||||
$library_path = (isset($library_config->path)) ? $library_config->path : "lib/htmlpurifier/HTMLPurifier.auto.php";
|
||||
|
||||
require_once($library_path);
|
||||
|
||||
$purifier_config = HTMLPurifier_Config::createDefault();
|
||||
|
||||
if(isset($library_config->doctype))
|
||||
{
|
||||
$purifier_config->set("HTML.Doctype", $library_config->doctype);
|
||||
}
|
||||
|
||||
if(isset($library_config->encoding))
|
||||
{
|
||||
$purifier_config->set("Core.Encoding", $library_config->encoding);
|
||||
}
|
||||
|
||||
$purifier_config->set("Cache.SerializerPath", "{$tmp_dir}/cphp/cache/htmlpurifier");
|
||||
|
||||
$cphp_purifier = new HTMLPurifier($purifier_config);
|
||||
$cphp_hash_purifier_config = md5(serialize($purifier_config));
|
||||
|
||||
function purify_html($input, $cache_duration = 3600, $config = null)
|
||||
{
|
||||
if(isset($config))
|
||||
{
|
||||
$config->set("Cache.SerializerPath", "{$tmp_dir}/cphp/cache/htmlpurifier");
|
||||
$cphp_purifier = new HTMLPurifier($config);
|
||||
$hash_config = md5(serialize($config));
|
||||
}
|
||||
else
|
||||
{
|
||||
global $cphp_purifier;
|
||||
global $cphp_hash_purifier_config;
|
||||
$hash_config = $cphp_hash_purifier_config;
|
||||
}
|
||||
|
||||
$hash_input = md5($input) . md5($input . "x");
|
||||
$memcache_key = "purify_{$hash_config}_{$hash_input}";
|
||||
|
||||
if($result = mc_get($memcache_key))
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $cphp_purifier->purify($input);
|
||||
mc_set($memcache_key, $result, $cache_duration);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue