summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorroot2014-03-10 15:31:56 +0100
committerroot2014-03-10 15:31:56 +0100
commit833d72001d3df1680913759ff760708766618eb8 (patch)
tree33bb53833e39063e523ee76cd54bab305590e5b3 /www
parent432275ce705b4e418b550eb99c45dd46ca1b3fd3 (diff)
downloadfiles.iamfabulous.de-833d72001d3df1680913759ff760708766618eb8.tar.gz
starting to write the interface
Diffstat (limited to 'www')
-rw-r--r--www/.functions.php.swpbin0 -> 20480 bytes
-rw-r--r--www/.index.php.swpbin12288 -> 12288 bytes
-rw-r--r--www/functions.php14
-rw-r--r--www/index.php7
-rw-r--r--www/interface_functions.php5
-rw-r--r--www/select.php68
-rw-r--r--www/select_function.php23
7 files changed, 35 insertions, 82 deletions
diff --git a/www/.functions.php.swp b/www/.functions.php.swp
new file mode 100644
index 0000000..51599d7
--- /dev/null
+++ b/www/.functions.php.swp
Binary files differ
diff --git a/www/.index.php.swp b/www/.index.php.swp
index 7dc5069..ea0fadf 100644
--- a/www/.index.php.swp
+++ b/www/.index.php.swp
Binary files differ
diff --git a/www/functions.php b/www/functions.php
index c1cdca6..96f4010 100644
--- a/www/functions.php
+++ b/www/functions.php
@@ -2,7 +2,7 @@
/* --LOGIN-- */
-require_once("select_functions.php");
+require_once("select_function.php");
function login($db){
if($_SERVER['REQUEST_METHOD'] == 'POST') {
@@ -267,7 +267,7 @@ function get_404(){
*/
//}
-function show($db){
+function rewrite($db){
/* test if first argument a username or folder */
@@ -286,14 +286,10 @@ function show($db){
} else {
get_404();
}
- } else {
-
- /* everything was okay, so show the content, please */
-
- $content = select($db);
- return $content;
- //exit;
+ return false;
}
+
+ return true;
}
function failure($reason){
diff --git a/www/index.php b/www/index.php
index d1f86ee..77a29e6 100644
--- a/www/index.php
+++ b/www/index.php
@@ -3,6 +3,7 @@
session_start();
require_once("functions.php");
+require_once("interface_functions.php");
$db = new SQLite3("../database/sqlite.db");
@@ -49,7 +50,9 @@ if(empty($_GET)){
/* shows the user content, main function */
- $content = show($db);
- var_dump($content);
+ if(rewrite($db)){
+ $content = select($db);
+ show($content);
+ }
}
}
diff --git a/www/interface_functions.php b/www/interface_functions.php
new file mode 100644
index 0000000..0116fe6
--- /dev/null
+++ b/www/interface_functions.php
@@ -0,0 +1,5 @@
+<?
+
+function show($content){
+ var_dump($content);
+}
diff --git a/www/select.php b/www/select.php
deleted file mode 100644
index ffa12d1..0000000
--- a/www/select.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?
-
-session_start();
-
-if($_SESSION["login"]){
- $share="";
-} else {
- $share ="AND share='PUBLIC'";
-}
-
-$db = new SQLite3("../database/sqlite.db");
-
-function failure($reason){
- echo "A 404 error occurred. <br>";
- echo $reason;
- exit;
-}
-
-if(!empty($_GET["name"])){
- $user = $_GET["name"];
-} else {
- failure("No user input.");
-}
-
-$owner_db = $db->query("SELECT id FROM user WHERE name='" . SQLite3::escapeString($user) . "';");
-
-if(empty($owner_db)){
- failure("This user doesn't exist.");
-}
-
-$owner_ar = $owner_db->fetchArray(SQLITE3_NUM);
-$owner = $owner_ar[0];
-
-$folder_array_unsafe = explode("/",$_GET["folder"]);
-$length = count($folder_array_unsafe);
-
-
-$root_db = $db->query("SELECT id FROM files WHERE parent=0 AND owner=" . $owner . " AND folder='DIRECTORY' " . $share . ";");
-if(empty($root_db)){
- failure("There is something seriously wrong. If you are a human you should never read this. Mail the admin please.");
-}
-$root_ar = $root_db->fetchArray(SQLITE3_NUM);
-$root_id = $root_ar[0];
-$parentdir = SQLite3::escapeString($root_id);
-$temp_id = $root_id;
-
-
-for($i=0; $i<$length; $i++){
-
- if(!empty($folder_array_unsafe[$i])){
- $parentdir_db = $db->query("SELECT id, parent FROM files WHERE owner=" . $owner . " AND folder='DIRECTORY' " . $share . " AND parent=" . $parentdir . " AND name='" . SQLite3::escapeString($folder_array_unsafe[$i]) . "';");
- if(empty($parentdir_db)){
- failure("Database error.");
- }
- $prim_id = $parentdir_db->fetchArray(SQLITE3_NUM);
- if($parentdir != $prim_id[1]){
- failure("This folder doesn't exist. Folder: " . $folder_array_unsafe[$i]);
- }
-
- $parentdir = $prim_id[0];
- echo SQLite3::escapeString($folder_array_unsafe[$i]);
-
- echo "<br>";
- }
-}
-
-$content_db = $db->query("SELECT id, name, folder FROM files WHERE parent=" . $parentdir . " AND owner=" . $owner . ";");
-$content_ar = $conten_db->fetchArray(SQLITE3_NUM);
diff --git a/www/select_function.php b/www/select_function.php
index b83fe04..6e4bc66 100644
--- a/www/select_function.php
+++ b/www/select_function.php
@@ -1,3 +1,4 @@
+<?
function select($db){
if($_SESSION["login"]){
$share="";
@@ -47,9 +48,25 @@ function select($db){
}
}
- $content_db = $db->query("SELECT id, name, folder FROM files WHERE parent=" . $parentdir . " AND owner=" . $owner . ";");
- $content_ar = $conten_db->fetchArray(SQLITE3_NUM);
+// echo "parent: " . $parentdir . "<br>";
+ $content_db = $db->query("SELECT * FROM files WHERE parent=" . $parentdir . " AND owner=" . $owner . ";");
+// $content_ar = $content_db->fetchArray(SQLITE3_NUM);
- return $content_ar;
+ $count=0;
+ while($row = $content_db->fetchArray(SQLITE3_NUM)){
+ $content[$count][0] = $row[0];
+ $content[$count][1] = $row[1];
+ $content[$count][2] = $row[2];
+ $content[$count][3] = $row[3];
+ $content[$count][4] = $row[4];
+ $content[$count][5] = $row[5];
+ $content[$count][6] = $row[6];
+ $content[$count][7] = $row[7];
+ $content[$count][8] = $row[8];
+ //echo "<a href='/". $user . "/" . $content[$count][3] . "'>" . $content[$count][3] . "</a><br>";
+ $count++;
+ }
+
+ return $content;
}