Page MenuHomeDevCentral

No OneTemporary

This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
diff --git a/includes/core.php b/includes/core.php
index 6f2aec4..862f9f4 100755
--- a/includes/core.php
+++ b/includes/core.php
@@ -1,345 +1,336 @@
<?php
/*
* Keruald, core libraries for Pluton and Xen engines.
* (c) 2010, Sébastien Santoro aka Dereckson, some rights reserved
* Released under BSD license
*
* Core
*
* 0.1 2010-02-27 2:04 DcK
*/
////////////////////////////////////////////////////////////////////////////////
/// ///
/// Configures PHP and loads site-wide used libraries ///
/// ///
////////////////////////////////////////////////////////////////////////////////
//Disables register globals
ini_set('register_globals', 'off');
//Reports all errors, help notices (including STRICT in PHP 6)
error_reporting(E_ALL & ~E_NOTICE);
//Load libraries
include_once("config.php"); //Site config
include_once("error.php"); //Error management
include_once("mysql.php"); //MySQL layer
include_once("session.php"); //Sessions handler
////////////////////////////////////////////////////////////////////////////////
/// ///
/// Information helper functions ///
/// ///
////////////////////////////////////////////////////////////////////////////////
/*
* Gets the username matching specified user id
* @param string $user_id the user ID
* @return string the username
*/
function get_username ($user_id) {
global $db;
$user_id = $db->sql_escape($user_id);
$sql = 'SELECT username FROM '. TABLE_USERS . " WHERE user_id = '$userid'";
return $db->sql_query_express($sql, "Can't get username from specified user id");
}
/*
* Gets the user id matching specified username
* @param string $username the username
* @return string the user ID
*/
function get_userid ($username) {
global $db;
$username = $db->sql_escape($username);
$sql = 'SELECT user_id FROM '. TABLE_USERS . " WHERE username LIKE '$username'";
return $db->sql_query_express($sql, "Can't get user id from specified username");
}
////////////////////////////////////////////////////////////////////////////////
/// ///
/// Misc helper functions ///
/// ///
////////////////////////////////////////////////////////////////////////////////
//Plural management
/*
* Gets a "s" if the specified amount requests the plural
* @param mixed $amount the quantity (should be numeric)
* @return string 's' if the amount is greater or equal than 2 ; otherwise, ''
*/
function s ($amount) {
if ($amount >= 2 || $amount <= -2 ) return 's';
}
/*
* Prints human-readable information about a variable, wrapped in a <pre> block
* @param mixed $mixed the variable to dump
*/
function dprint_r ($mixed) {
echo '<pre>';
print_r($mixed);
echo '</pre>';
}
/*
* Generates a new GUID
* @return string a guid (without {})
*/
function new_guid () {
//The guid chars
$chars = explode(',', 'a,b,c,d,e,f,0,1,2,3,4,5,6,7,8,9');
//Let's build our 36 characters string
//e.g. 68ed40c6-f5bb-4a4a-8659-3adf23536b75
$guid = "";
for ($i = 0 ; $i < 36 ; $i++) {
if ($i == 8 || $i == 13 || $i == 18 || $i == 23) {
//Dashes at position 9, 14, 19 and 24
$guid .= "-";
} else {
//0-f hex digit elsewhere
$guid .= $chars[mt_rand() % sizeof($characters)];
}
}
return $guid;
}
/*
* Determines if the expression is a valid guid (in uuid notation, without {})
* @param string $expression the guid to check
* @return true if the expression is a valid guid ; otherwise, false
*/
function is_guid ($expression) {
//We avoid regexp to speed up the check
//A guid is a 36 characters string
if (strlen($expression) != 36) return false;
$expression = strtolower($expression);
for ($i = 0 ; $i < 36 ; $i++) {
if ($i == 8 || $i == 13 || $i == 18 || $i == 23) {
//with dashes
if ($expression[$i] != '-') return false;
} else {
//and hex numbers
if (!is_numeric($expression[$i]) && $expression[$i] != 'a' && $expression[$i] != 'b' && $expression[$i] != 'c' && $expression[$i] != 'd' && $expression[$i] != 'e' && $expression[$i] != 'f' ) return false;
}
}
return true;
}
/*
* Gets file extension
* @param string $file the file to get the extension
*/
function get_extension ($file) {
$dotPosition = strrpos($file, ".");
return substr($file, $dotPosition + 1);
}
/**
* Determines if a string starts with specified substring
*
* @param string $haystack the string to check
* @param string $needle the substring to determines if it's the start
* @param boolean $case_sensitive determines if the search must be case sensitive
* @return boolean true if $haystack starts with $needle ; otherwise, false.
*/
function string_starts_with ($haystack, $needle, $case_sensitive = true) {
if (!$case_sensitive) {
$haystack = strtoupper($haystack);
$needle = strtoupper($needle);
}
if ($haystack == $needle) return true;
return strpos($haystack, $needle) === 0;
}
/**
* Gets the portion of the string between $includeFrom and $includeTo
*/
function string_between ($haystack, $from, $to, $includeFrom = false, $includeTo = false) {
//Gets start position
$pos1 = strpos($haystack, $from);
if ($pos1 === false) {
return "";
}
if (!$includeFrom) $pos1 += strlen($from);
//Gets end position
$pos2 = strpos($haystack, $to, $pos1 + strlen($from));
if ($pos2 === false) {
return substr($haystack, $pos1);
}
if ($includeTo) $pos2 += strlen($to);
//Gets middle part
return substr($haystack, $pos1, $pos2 - $pos1);
}
////////////////////////////////////////////////////////////////////////////////
/// ///
/// URL helpers functions ///
/// ///
////////////////////////////////////////////////////////////////////////////////
/*
* Gets URL
* @return string URL
*/
function get_url () {
global $Config;
if (func_num_args() > 0) {
$pieces = func_get_args();
return $Config['BaseURL'] . '/' . implode('/', $pieces);
} elseif ($Config['BaseURL'] == "" || $Config['BaseURL'] == "/index.php") {
return "/";
} else {
return $Config['BaseURL'];
}
}
/*
* Gets page URL
* @return string URL
*/
function get_page_url () {
$url = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
if (substr($url, -10) == "/index.php") {
return substr($url, 0, -9);
}
return $url;
}
/*
* Gets server URL
* @todo find a way to detect https:// on non standard port
* @return string the server URL
*/
function get_server_url () {
switch ($port = $_SERVER['SERVER_PORT']) {
case '80':
return "http://$_SERVER[SERVER_NAME]";
case '443':
return "https://$_SERVER[SERVER_NAME]";
default:
return "http://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]";
}
}
/*
* Gets $_SERVER['PATH_INFO'] or computes the equivalent if not defined.
* @return string the relevant URL part
*/
function get_current_url () {
global $Config;
-
+
//Gets relevant URL part from relevant $_SERVER variables
if (array_key_exists('PATH_INFO', $_SERVER)) {
//Without mod_rewrite, and url like /index.php/controller
//we use PATH_INFO. It's the easiest case.
return $_SERVER["PATH_INFO"];
}
-
+
//In other cases, we'll need to get the relevant part of the URL
$current_url = get_server_url() . $_SERVER['REQUEST_URI'];
-
+
//Relevant URL part starts after the site URL
$len = strlen($Config['SiteURL']);
-
+
//We need to assert it's the correct site
if (substr($current_url, 0, $len) != $Config['SiteURL']) {
dieprint_r(GENERAL_ERROR, "Edit includes/config.php and specify the correct site URL<br /><strong>Current value:</strong> $Config[SiteURL]<br /><strong>Expected value:</strong> a string starting by " . get_server_url(), "Setup");
}
-
- if (array_key_exists('REDIRECT_URL', $_SERVER)) {
- //With mod_rewrite, we can use REDIRECT_URL
- //We takes the end of the URL, ie *FROM* $len position
- return substr(get_server_url() . $_SERVER["REDIRECT_URL"], $len);
- }
-
- //Last possibility: use REQUEST_URI, but remove QUERY_STRING
- //If you need to edit here, use $_SERVER['REQUEST_URI']
- //but you need to discard $_SERVER['QUERY_STRING']
-
- //We takes the end of the URL, ie *FROM* $len position
- $url = substr(get_server_url() . $_SERVER["REQUEST_URI"], $len);
-
- //But if there are a query string (?action=... we need to discard it)
+
+ //Last possibility: use REQUEST_URI or REDIRECT_URL, but remove QUERY_STRING
+ //TODO: handle the case of a nginx misconfiguration, where the query_string have been removed.
+ // e.g. 'fastcgi_param SCRIPT_FILENAME $document_root/index.php;' will remove the QS.
+ // (a working could be $document_root/index.php?$query_string);
+ $url = array_key_exists('REDIRECT_URL', $_SERVER) ? $_SERVER["REDIRECT_URL"] : $_SERVER["REQUEST_URI"];
+ $url = substr(get_server_url() . $url, $len);
if ($_SERVER['QUERY_STRING']) {
return substr($url, 0, strlen($url) - strlen($_SERVER['QUERY_STRING']) - 1);
}
-
return $url;
}
/*
* Gets an array of url fragments to be processed by controller
* @return array an array containing URL fragments
*/
function get_current_url_fragments () {
$url_source = get_current_url();
if ($url_source == '/index.php') return array();
return explode('/', substr($url_source, 1));
}
/**
* Gets the URL for the specified resources
*
* @param ... string a arbitray number of path info
*/
function get_url_for () {
global $Config;
$url = get_server_url() . '/' . $Config[BaseURL];
if (func_num_args()) {
$url .= implode('/', func_get_args());
}
return $url;
}
////////////////////////////////////////////////////////////////////////////////
/// ///
/// URL xmlHttpRequest helpers functions ///
/// ///
////////////////////////////////////////////////////////////////////////////////
/*
* Gets an hash value to check the integrity of URLs in /do.php calls
* @param Array $args the args to compute the hash
* @return the hash paramater for your xmlHttpRequest url
*/
function get_xhr_hash ($args) {
global $Config;
array_shift($args);
return md5($_SESSION['ID'] . $Config['SecretKey'] . implode('', $args));
}
/*
* Gets the URL to call do.php, the xmlHttpRequest controller
* @return string the xmlHttpRequest url, with an integrity hash
*/
function get_xhr_hashed_url () {
global $Config;
$args = func_get_args();
$args[] = get_xhr_hash($args);
return $Config['DoURL'] . '/' . implode('/', $args);
}
/*
* Gets the URL to call do.php, the xmlHttpRequest controller
* @return string the xmlHttpRequest url
*/
function get_xhr_url () {
global $Config;
$args = func_get_args();
return $Config['DoURL'] . '/' .implode('/', $args);
}
diff --git a/index.php b/index.php
index 8cf445a..d3ffd63 100755
--- a/index.php
+++ b/index.php
@@ -1,85 +1,84 @@
-<?php
-
-/**
- * Keruald, core libraries for Pluton and Xen engines.
- * (c) 2010, Sébastien Santoro aka Dereckson, some rights reserved
- * Released under BSD license
- *
- * Application entry point
- *
- * Keruald is mainly a repository for common libraries elements between
- * engines like Pluton (content-oriented site) and Xen (MVC).
- *
- * You should consider to start with one of those.
- *
- */
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// Initialization
-///
-
-define('IN_KERUALD', true);
-define('IN_PLUTON', true);
-
-//Keruald libraries
-include('includes/core.php');
-
-//Pluton libraries
-include('includes/document.php');
-
-//Site libraries
-include('includes/core2.php');
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// Session
-///
-
-//[TODO] If your session contains classes, and you don't implement __autoload,
-//you've to require those items before session_start();
-//You can implement this here or in _includes/sessions.php
-
-//Starts a new session or recovers current session
-$Session = Session::load();
-
-//Handles login or logout
-//include("includes/login.php");
-
-//Gets current user information
-$CurrentUser = $Session->get_logged_user();
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// Your application initialization logic
-///
-
-//[TODO] Loads your template engine or prepares the document to print
-//[TODO] Loads languages file if you're into L10n
-
-////////////////////////////////////////////////////////////////////////////////
-///
-/// Serves the requested page
-///
-
-/**
- * Forces bare display for broken mobiles
- *
- * @return true if header and footer must be skipped ; otherwise, false.
- */
-function force_bare_display () {
- if (strpos($_SERVER["HTTP_USER_AGENT"], " NetFront/") !== false) {
- return true;
- }
- return false;
-}
-
-$url = get_current_url();
-
-$document = new Document($url);
-if (force_bare_display()) {
- $document->noheader = true;
- $document->nofooter = true;
-}
-$document->render();
-
+<?php
+
+/**
+ * Keruald, core libraries for Pluton and Xen engines.
+ * (c) 2010, Sébastien Santoro aka Dereckson, some rights reserved
+ * Released under BSD license
+ *
+ * Application entry point
+ *
+ * Keruald is mainly a repository for common libraries elements between
+ * engines like Pluton (content-oriented site) and Xen (MVC).
+ *
+ * You should consider to start with one of those.
+ *
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// Initialization
+///
+
+define('IN_KERUALD', true);
+define('IN_PLUTON', true);
+
+//Keruald libraries
+include('includes/core.php');
+
+//Pluton libraries
+include('includes/document.php');
+
+//Site libraries
+include('includes/core2.php');
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// Session
+///
+
+//[TODO] If your session contains classes, and you don't implement __autoload,
+//you've to require those items before session_start();
+//You can implement this here or in _includes/sessions.php
+
+//Starts a new session or recovers current session
+$Session = Session::load();
+
+//Handles login or logout
+//include("includes/login.php");
+
+//Gets current user information
+$CurrentUser = $Session->get_logged_user();
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// Your application initialization logic
+///
+
+//[TODO] Loads your template engine or prepares the document to print
+//[TODO] Loads languages file if you're into L10n
+
+////////////////////////////////////////////////////////////////////////////////
+///
+/// Serves the requested page
+///
+
+/**
+ * Forces bare display for broken mobiles
+ *
+ * @return true if header and footer must be skipped ; otherwise, false.
+ */
+function force_bare_display () {
+ if (strpos($_SERVER["HTTP_USER_AGENT"], " NetFront/") !== false) {
+ return true;
+ }
+ return false;
+}
+
+$url = get_current_url();
+$document = new Document($url);
+if (force_bare_display()) {
+ $document->noheader = true;
+ $document->nofooter = true;
+}
+$document->render();
+
diff --git a/lists/ListOperation.php b/lists/ListOperation.php
new file mode 100755
index 0000000..900d292
--- /dev/null
+++ b/lists/ListOperation.php
@@ -0,0 +1,49 @@
+<?php
+class ListOperation {
+ /**
+ * Adds two lists
+ *
+ * @param Array $a The left list
+ * @param Array $b The right list
+ * @return Array The resultant list
+ */
+ public static function Add ($a, $b) {
+ return array_merge($a, $b);
+ }
+
+ /**
+ * Intersects two lists
+ *
+ * @param Array $a The left list
+ * @param Array $b The right list
+ * @return Array The resultant list
+ */
+ public static function Intersect ($a, $b) {
+ if (count($a) == 0 || count($b) == 0) { return array(); }
+
+ return array_intersect($a, $b);
+ }
+
+ /**
+ * Substracts a list from another list
+ *
+ * @param Array $a The left list
+ * @param Array $b The right list
+ * @return Array The resultant list
+ */
+ public static function Substract ($a, $b) {
+ if (count($b) == 0) { return $a; }
+ $result = array();
+ foreach ($a as $key => $value) {
+ $toRemove = false;
+ foreach ($b as $itemToRemove) {
+ if ($value == $itemToRemove) {
+ $toRemove = true;
+ break;
+ }
+ }
+ if (!$toRemove) $result[$key] = $value;
+ }
+ return $result;
+ }
+}
diff --git a/lists/RegexpFactory.php b/lists/RegexpFactory.php
new file mode 100755
index 0000000..c7f5381
--- /dev/null
+++ b/lists/RegexpFactory.php
@@ -0,0 +1,110 @@
+<?php
+
+/**
+ * Performs operation from given a regular expression
+ */
+class RegexpFactory {
+ /**
+ * The regular expression
+ * @var string
+ */
+ public $expression;
+
+ /**
+ * The last error
+ * @var string
+ */
+ public $lastError;
+
+ /**
+ * Initializes a new instance of the RegexpFactory object.
+ *
+ * @param string The regular expression
+ */
+ function __construct ($expression) {
+ $this->expression = $expression;
+ }
+
+ /**
+ * Replaces an expression using regexp, a similar way Apache mod_rewrite and Nginx wreplace do.
+ *
+ * @param string $haystack The expression to perform a replacement on
+ * @param string $replaceExpression The format of the result string
+ * @return string The replaced string
+ */
+ function replace ($haystack, $replaceExpression) {
+ return preg_replace($this->expression, $replaceExpression, $haystack);
+ }
+
+ /**
+ * Encloses the regular expression with delimiters.
+ */
+ function addDelimiters () {
+ $delimiters = ['/', '@', '#', '~', '+', '%', '♦', 'µ', '±', '☞'];
+ //TODO: check if it's okay to use UTF-8 characters as delimiters
+ foreach ($delimiters as $delimiter) {
+ if (strpos($this->expression, $delimiter) === false) {
+ $this->expression = $delimiter . $this->expression . $delimiter;
+ return;
+ }
+ }
+ throw new Exception("Can't delimite regexp $this->expression");
+ }
+
+ /**
+ * Determines if the specified expression is valid.
+ *
+ * @return bool true if the expression is valid; otherwise, false.
+ */
+ public function isValid () {
+ $this->lastError = '';
+ set_error_handler('self::handleErrors');
+ $result = preg_match($this->expression, null);
+ restore_error_handler();
+ if ($this->lastError === '' && $result === false) {
+ $this->lastError = self::getPCREError();
+ }
+ return $result !== false;
+ }
+
+ /**
+ * Callback for error handler
+ *
+ * @param int $errno he level of the error raised
+ * @param string $errstr the error message
+ * @return bool if false, the normal error handler continues
+ */
+ private function handleErrors ($errno, $errstr) {
+ if ($errno == 2 && substr($errstr, 0, 14) == 'preg_match(): ') {
+ $this->lastError = substr($errstr, 14);
+ if (substr($this->lastError, 0, 20) == 'Compilation failed: ') {
+ $this->lastError = ucfirst(substr($this->lastError, 20));
+ }
+ return true;
+ }
+ message_die(
+ GENERAL_ERROR,
+ $errstr . "<p>Please report this bug. This error should be handled by the regexp factory.</p>",
+ 'Regexp factory error'
+ );
+ }
+
+ /**
+ * Gets a string with an English error message matching the last PCRE error.
+ *
+ * @return The error message of the last PCRE library error.
+ */
+ public static function getPCREError() {
+ $errors = array(
+ PREG_NO_ERROR => 'No error',
+ PREG_INTERNAL_ERROR => 'There was an internal PCRE error',
+ PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted',
+ PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted',
+ PREG_BAD_UTF8_ERROR => 'The offset didn\'t correspond to the begin of a valid UTF-8 code point',
+ PREG_BAD_UTF8_OFFSET_ERROR => 'Malformed UTF-8 data',
+ );
+
+ return $errors[preg_last_error()];
+ }
+}
+?>
diff --git a/lists/_documents.xml b/lists/_documents.xml
new file mode 100644
index 0000000..f3aba15
--- /dev/null
+++ b/lists/_documents.xml
@@ -0,0 +1,17 @@
+<documents topic="gadgets">
+ <document>
+ <article>index</article>
+ <title>Lists tools</title>
+ <description>Tools manipulating lists.</description>
+ </document>
+ <document>
+ <article>operations</article>
+ <title>List operations</title>
+ <description>Adds, subtracts or intersects lists.</description>
+ </document>
+ <document>
+ <article>replace</article>
+ <title>List replace</title>
+ <description>Performs regexp replacement in a list</description>
+ </document>
+</documents>
diff --git a/lists/index.php b/lists/index.php
new file mode 100755
index 0000000..8491dc4
--- /dev/null
+++ b/lists/index.php
@@ -0,0 +1,5 @@
+<h2>Lists tools</h2>
+<ul>
+ <li><strong><a href="/lists/operations">Operations</a></strong> — Adds, subtracts or intersects lists.</li>
+ <li><strong><a href="/lists/replace">Replace</a></strong> — Replacement in a list, using regexp. Similar to the Apache mod_rewrite RewriteRule or Nginx replace syntax.</li>
+</ul>
diff --git a/lists/operations.php b/lists/operations.php
new file mode 100755
index 0000000..65f60b7
--- /dev/null
+++ b/lists/operations.php
@@ -0,0 +1,43 @@
+<?php
+ $result = '';
+ if (array_key_exists('operation', $_REQUEST)) {
+ require('ListOperation.php');
+ $operation = ucfirst($_REQUEST["operation"]);
+ if (method_exists('ListOperation', $operation)) {
+ $left = explode("\n", $_REQUEST['lists'][0]);
+ $right = explode("\n", $_REQUEST['lists'][1]);
+ $result = implode("\n", ListOperation::$operation($left, $right));
+ } else {
+ $result = "// Unknown list operation.";
+ }
+ }
+?>
+ <form name="lists" method="post" action="/lists/operations">
+ <div class="large-12 columns">
+ <div class="row">
+ <div class="large-3 columns">
+ <h6 class="panel" style="text-align: center;">List A</h6>
+ <textarea name="lists[0]" rows=20><?= $_REQUEST['lists'][0] ?></textarea>
+ </div>
+
+ <div class="large-1 columns">
+ <h6 class="panel" style="text-align: center;">Operation</h6>
+ <label for="operation_add"><input name="operation" value="add" type="radio" id="operation_add"> <i class="gen-enclosed foundicon-plus"> add</i></label>
+ <label for="operation_intersect"><input name="operation" value="intersect" CHECKED type="radio" id="operation_intersect"> <i class="gen-enclosed foundicon-remove"> intersect</i></label>
+ <label for="operation_substract"><input name="operation" value="substract" type="radio" id="operation_substract"> <i class="gen-enclosed foundicon-minus"> substract</i></label>
+ <p>&nbsp;</p>
+ <p><input type="submit" value="Compute" class="button" /></p>
+ </div>
+
+ <div class="large-3 columns">
+ <h6 class="panel" style="text-align: center;">List B</h6>
+ <textarea name="lists[1]" rows=20><?= $_REQUEST['lists'][1] ?></textarea>
+ </div>
+
+ <div class="large-3 columns">
+ <h6 class="panel" style="text-align: center;">Result</h6>
+ <textarea name="lists[2]" rows=20><?= $result ?></textarea>
+ </div>
+ </div>
+ </div>
+ </form>
diff --git a/lists/replace.php b/lists/replace.php
new file mode 100755
index 0000000..908c004
--- /dev/null
+++ b/lists/replace.php
@@ -0,0 +1,81 @@
+<?php
+include('RegexpFactory.php');
+
+$result = '';
+$enable_join = array_key_exists('join', $_REQUEST) && $_REQUEST["join"] == 'on';
+
+if (array_key_exists('expression', $_REQUEST)) {
+ if (array_key_exists('lists', $_REQUEST) && array_key_exists(0, $_REQUEST['lists']) && array_key_exists('replacement', $_REQUEST)) {
+ $regexp = new RegexpFactory($_REQUEST['expression']);
+ $regexp->addDelimiters();
+ if ($regexp->isValid()) {
+ $items = explode("\n", $_REQUEST['lists'][0]);
+ $replace_callback = function (&$item, $key, $replaceExpression) use ($regexp) {
+ $item = $regexp->replace(trim($item), $replaceExpression);
+ };
+ array_walk($items, $replace_callback, $_REQUEST['replacement']);
+ $result = join("\n", $items);
+ if ($enable_join) {
+ $result = join($_REQUEST["joinglue"], $items);
+ }
+ }
+ }
+ //If no list is given, or the replacement expression is blank, the result list is blank.
+}
+?>
+ <script>
+ function updateUI () {
+ if (document.getElementById("joinglue").value != "" && !document.getElementById("join").checked) {
+ //Checks the enable box when a glue string is provided
+ document.getElementById("join").checked = true;
+ $("#join-checkbox .checkbox").addClass("checked");
+ }
+ }
+ </script>
+ <form name="lists" method="post" action="/lists/replace" class="custom">
+ <div class="row collapse">
+ <div class="one mobile-one columns">
+ <span class="prefix">Replace</span>
+ </div>
+ <div class="five mobile-three columns">
+ <input
+ name="expression" id="expression" type="text"
+ placeholder="The Nginx or Apache mod_rewrite-like regular expression"
+ value="<?= $_REQUEST['expression'] ?>"
+ />
+ <?php if (isset($regexp) && $regexp->lastError) echo '<small class="error" style="font-weight: 400;">', $regexp->lastError, '</small>'; ?>
+ </div>
+ <div class="five mobile-three columns">
+ <input
+ name="replacement" id="replacement" type="text"
+ placeholder="The list format. Use $1, $2, … to use the regexp groups."
+ value="<?= $_REQUEST['replacement'] ?>"
+ />
+ </div>
+ <div class="one mobile-one columns">
+ <input type="submit" class="button expand postfix" value="Format" />
+ </div>
+ </div>
+ <div class="row collapse">
+ <div class="one mobile-one columns">
+ <span class="prefix">Join</span>
+ </div>
+ <div class="ten mobile-six columns">
+ <input name="joinglue" id="joinglue" type="text" placeholder="Glue text to join the list into a string. Leave blank to concat without seperator. Don't forget to check the checkbox to enable." value="<?= $_REQUEST['joinglue'] ?>" onchange="updateUI();" />
+ </div>
+ <div class="one mobile-one columns" style="text-align: center;">
+ <span id="join-checkbox"><input type="checkbox" id="join" name="join" <?= $enable_join ? 'checked ' : '' ?>/><br /><label for="join">Enable</label></span>
+ </div>
+
+ </div>
+ <div class="row collapse">
+ <div class="six columns">
+ <textarea name="lists[0]" rows="16" style="width: 99%;" placeholder="The list to format"><?= $_REQUEST['lists'][0] ?></textarea>
+ </div>
+ <div class="six columns">
+ <textarea name="lists[1]" rows="16" style="width: 99%;" placeholder="The formatted list will appear here."><?= $result ?></textarea>
+ </div>
+ </div>
+ </form>
+ <p><strong>Documentation resources:</strong> <a href="http://perldoc.perl.org/perlre.html">PCRE syntax</a> • <a href="http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/">Regular Expressions Cheat Sheet</a>
+ <br /><strong>Note:</strong> Write your regexp without delimiter.</p>
diff --git a/themes/RalfFallsIntoFoundation/footer.php b/themes/RalfFallsIntoFoundation/footer.php
index 04dba64..52681d4 100755
--- a/themes/RalfFallsIntoFoundation/footer.php
+++ b/themes/RalfFallsIntoFoundation/footer.php
@@ -1,63 +1,67 @@
</div></section>
<!-- Footer -->
<footer><div class="row">
<div class="twelve columns"><hr />
<div class="row">
<div class="three columns">
<p>This site is a repository of tools.</p>
<p>This is also an experiment to create a site based on Pluton, Foundation, Hg <span class="ampersand">&</span> Nasqueron.</p>
</div>
<div class="three columns">
<dl>
<dt>Gerrit</dt>
<dd><a href="/wikimedia/dev/feeds/">Activity feeds</a></dd>
<dd>RSS generator</dd>
</dl>
</div>
<div class="three columns">
<dl>
<dt>Network</dt>
<dd><a href="/network/mx.php">MX</a></dd>
- </dl>
- <dl>
+
+ <dt>Lists</dt>
+ <dd><a href="/lists/operations">Lists operations</a></dd>
+ <dd><a href="/lists/replace">Lists RegExp replace</a></dd>
+
<dt>Color</dt>
<dd><a href="/color/screen/">Random color screen</a></dd>
<dd><a href="/color/screen/879497">Gray-blue screen</a></dd>
</dl>
</div>
<div class="three columns">
<dl>
<dt>Gadgets</dt>
<dd><a href="/gadgets/motd-variations.php">MOTD in Jive <span class="ampersand">&</span> Valspeak</a></dd>
+
<dt>Start pages</dt>
<dd><a href="/lex">Lex</a></dd>
</dl>
</div>
</div>
</div>
<div class="twelve columns"><hr />
<div class="row extrainfos">
<div class="six columns">
<p><i class="general foundicon-settings"></i> <strong>Options:</strong> <a href="javascript:SetUITonality('dark');">dark mode</a> | <a href="javascript:SetUITonality('light');">light mode</a></p>
</div>
</div>
<div class="row extrainfos">
<div class="six columns">
<p><i class="general foundicon-globe"></i> <strong>Crafted by</strong> <a href="http://www.dereckson.be/">Dereckson</a> | <strong>Powered by</strong> <a href="http://keruald.sf.net">Keruald/Pluton</a> <span class="ampersand">&</span> <a href="http://foundation.zurb.com/">Foundation</a>.</p>
</div>
<div class="six columns">
<p class="right"><i class="general foundicon-flag"></i> <strong>Git revision:</strong> <?= substr(`git rev-parse HEAD`, 0, 7) ?> | <strong>Version:</strong> alpha preview</p>
</div>
</div>
</div>
</div></footer>
<script src="/javascripts/foundation.min.js"></script>
<script src="/javascripts/jquery.cookie.js"></script>
<script src="/javascripts/app.js"></script>
<?= $document->footer ?>
</body>
</html>

File Metadata

Mime Type
text/x-diff
Expires
Thu, Sep 18, 07:07 (13 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2990150
Default Alt Text
(31 KB)

Event Timeline