Page MenuHomeWolfplex

No OneTemporary

diff --git a/_includes/CommonData.php b/_includes/CommonData.php
new file mode 100755
index 0000000..00054cd
--- /dev/null
+++ b/_includes/CommonData.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * This file provides arrays containing datas about Wolflex and Wolfplex Hackerspace
+ * Any static field in an API should use these values instead to hardcode them.
+ */
+
+//Data related to Wolfplex
+$WolfplexData = [
+ 'name' => 'Wolfplex',
+ 'oid' => '1.3.6.1.4.1.37822',
+];
+
+//Data related to the hackerspace
+$HackerspaceData = [
+ 'name' => 'Wolfplex Hackerspace',
+ 'logo' => [
+ 'default' => 'http://www.wolfplex.org/img/logo496.png',
+ ],
+ 'mail' => [
+ 'contact' => 'hackerspace@wolfplex.org',
+ 'stages' => 'participate@wolfplex.org',
+ ],
+ 'places' => [
+ 'siegeSocial' => [
+ 'address' => 'Rue de la Science 14 - 6000 Charleroi - Belgium',
+ 'coords' => [50.4114737, 4.4464617],
+ ],
+ 'space' => [
+ 'address' => '/dev/null',
+ 'coords' => [50.40603, 4.46884], //Station de métro Pensée as temporary coords
+ //'address' => 'Chaussée de Gilly 18 - 6220 Fleurus - Belgium',
+ //'coords' => [50.455819, 4.527694], //Lionel place
+ ],
+ ],
+ 'URL' => [
+ 'default' => 'http://www.wolfplex.org/',
+ 'api' => 'http://api.wolfplex.org',
+ 'bitbucket' => 'http://www.bitbucket.org/wolfplex/',
+ 'github' => 'https://github.com/wolfplex',
+ 'intranet' => 'http://www.wolfplex.org/members/',
+ 'IRC' => 'irc://irc.freenode.net/wolfplex/',
+ 'IRCWebChat' => 'http://irc.lc/wolfplex',
+ 'ML' => 'http://discuss.hackerspaces.be/listinfo.cgi/wolfplex-hackerspaces.be',
+ 'print' => 'www.wolfplex.org',
+ 'projects' => 'http://www.wolfplex.org/wiki/Cat%C3%A9gorie:Project',
+ 'twitter' => 'http://www.twitter.com/wolfplex',
+ 'wiki' => 'http://www.wolfplex.org',
+ 'wikiRecentChangesFeed' => 'http://www.wolfplex.org/w/index.php?title=Sp%C3%A9cial:Modifications_r%C3%A9centes&feed=atom',
+ ],
+ 'accounts' => [
+ 'twitter' => "@Wolfplex",
+ 'foursquare' => "4df75cd61fc7393b579fcc8e",
+ ],
+ 'lists' => [
+ 'default' => 'wolfplex@discuss.hackerspaces.be',
+ ],
+];
\ No newline at end of file
diff --git a/_includes/HackerspaceOpenStatus.php b/_includes/HackerspaceOpenStatus.php
new file mode 100755
index 0000000..c5a07cb
--- /dev/null
+++ b/_includes/HackerspaceOpenStatus.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Class to determine if the space is currently open or closed
+ */
+class HackerspaceOpenStatus {
+ private $isOpen;
+ public $date;
+ public $who;
+ public $comment;
+
+ /**
+ * Initializes a new instance of the HackerspaceOpenStatus object
+ *
+ * @param bool $isOpen true if the space is open; otherwise, false
+ * @param int $date The unixtime of the last modification
+ * @param string $who The name of the last person to have updated the status
+ * @param string $comment The comment associated to this operation
+ */
+ public function __construct ($isOpen, $date = null, $who = '', $comment = '') {
+ $this->isOpen = $isOpen;
+ $this->date = ($date === null) ? time() : $date;
+ $this->who = $who;
+ $this->comment = $comment;
+ }
+
+ /**
+ * Determines if the space is currently open or closed
+ *
+ * @return bool True if the space is currently open; otherwise, false.
+ */
+ public function IsOpen () {
+ return $this->isOpen;
+ }
+}
+
+/**
+ * Determines the hackerspace open status, using the wiki
+ */
+class MediaWikiHackerspaceOpenStatus extends HackerspaceOpenStatus {
+ /**
+ * Initializes a new instance of the HackerspaceOpenStatus object
+ */
+ public function __construct ($api_url, $page_title, $open_content = 'yes') {
+ //Gets the last revision content and metadata from the wiki
+ $url = "$api_url?action=query&prop=revisions&titles=$page_title&rvprop=timestamp|user|comment|content&format=json";
+ $data = json_decode(file_get_contents($url), true);
+ $data = array_pop($data['query']['pages']);
+ $data = $data['revisions'][0];
+
+ //Fills properties
+ parent::__construct(
+ $data['*'] == $open_content,
+ strtotime($data['timestamp']),
+ self::is_ip($data['user']) ? '' : $data['user'],
+ $data['comment']
+ );
+ }
+
+ /**
+ * Determines if the expression is a valid IPv4 or IPv6
+ *
+ * @param string $expression The expression to validate
+ * @return bool true if the expression is a valid IP; otherwise, false.
+ */
+ public static function is_ip ($expression) {
+ return
+ preg_match('/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/', $expression)
+ ||
+ preg_match('/^(?>(?>([a-f0-9]{1,4})(?>:(?1)){7}|(?!(?:.*[a-f0-9](?>:|$)){8,})((?1)(?>:(?1)){0,6})?::(?2)?)|(?>(?>(?1)(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})(?3)?::(?>((?1)(?>:(?1)){0,4}):)?)?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?4)){3}))$/iD', $expression);
+ ;
+ }
+}
+
+function get_hackerspace_open_status () {
+ return new MediaWikiHackerspaceOpenStatus(
+ 'http://www.wolfplex.org/w/api.php',
+ 'Template:IsOpen/status'
+ );
+}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 17, 5:24 PM (1 d, 4 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
46114
Default Alt Text
(4 KB)

Event Timeline