summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorNaglfar <naglfar@tilde.institute>2021-01-08 01:48:41 +0100
committerNaglfar <naglfar@tilde.institute>2021-01-08 01:48:41 +0100
commit4eebbfb79c42abd8ebcd7d1776f164588a3d16b0 (patch)
treeb30d4d039b3618b948ce95873a6df266a888dd44
parent37ce89d17dbff71c107db5bc280e1721dbaae6ad (diff)
downloadMightyWVMS-4eebbfb79c42abd8ebcd7d1776f164588a3d16b0.tar.gz
Add data management php scripts
-rw-r--r--php/definitions.php8
-rw-r--r--php/vm-procedures.php17
-rw-r--r--php/ws-procedures.php10
3 files changed, 35 insertions, 0 deletions
diff --git a/php/definitions.php b/php/definitions.php
new file mode 100644
index 0000000..3da4399
--- /dev/null
+++ b/php/definitions.php
@@ -0,0 +1,8 @@
+<?php // Variables and constants definition 
+$dpath = 'data/';
+$toc = 'toc.mvms';	  # Table of contents
+$common = 'common.mvms';  # common header/footer contents
+$channel = 'channel';	  # Channel index
+$cpath = 'mvms/';	  # Path of the contents
+$vid = 0;		  # default video
+?>
diff --git a/php/vm-procedures.php b/php/vm-procedures.php
new file mode 100644
index 0000000..3abb46f
--- /dev/null
+++ b/php/vm-procedures.php
@@ -0,0 +1,17 @@
+<?php
+$vindex = file($dpath.$mdata[3].'/'.$toc, FILE_IGNORE_NEW_LINES); 
+$cindex = file($dpath.$mdata[3].'/'.$channel, FILE_IGNORE_NEW_LINES);
+
+/* 1 parse the URL */
+$vdata = explode('/', $_SERVER['REQUEST_URI']);
+
+/* 2 security check */
+if(!empty($vdata[1]))
+  foreach($vindex as $i => $value)
+    if($vdata[1] == $value)
+      $vid = $i;
+
+$vdata = file($dpath.$mdata[3].'/'.$vid, FILE_IGNORE_NEW_LINES);
+$vdata[1] = date('M j, Y', $vdata[1]);
+$vdata[] = file_get_contents($dpath.$mdata[3].'/'.$cpath.$vid);
+?>
diff --git a/php/ws-procedures.php b/php/ws-procedures.php
new file mode 100644
index 0000000..5dc685a
--- /dev/null
+++ b/php/ws-procedures.php
@@ -0,0 +1,10 @@
+<?php
+//read the file and create array separate by new line
+$mdata = file($dpath.'/'.$common, FILE_IGNORE_NEW_LINES);
+
+# Language overwritten by the browser preference
+if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
+  $mdata[3] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0,2);
+
+$mdata = array_merge($mdata, file($dpath.$mdata[3].'/'.$common, FILE_IGNORE_NEW_LINES));
+?>