summaryrefslogtreecommitdiff
path: root/moe/includes
diff options
context:
space:
mode:
authorNeku <neku@pomf.se>2013-12-15 16:33:18 +0100
committerNeku <neku@pomf.se>2013-12-15 16:33:18 +0100
commit796f4329e6dd6b96426905468fc552d0af456ebf (patch)
tree9dde7b333e67551be0769ea628e946126bbaf0d0 /moe/includes
parentca784b878869279c95deaaadb754f17646e172dc (diff)
it will be ready sometime..
Diffstat (limited to 'moe/includes')
-rw-r--r--moe/includes/api.php15
-rw-r--r--moe/includes/core.php25
2 files changed, 37 insertions, 3 deletions
diff --git a/moe/includes/api.php b/moe/includes/api.php
index da0d652..8ac0a92 100644
--- a/moe/includes/api.php
+++ b/moe/includes/api.php
@@ -17,6 +17,21 @@ if(isset($_GET['do'])){
register($_POST['email'], $_POST['pass']);
break;
+ case "cp":
+ header('Location: ../panel');
+ break;
+
+ case "search":
+ search($_GET['q']);
+ break;
+
+ case "logout":
+ session_unset();
+ session_destroy();
+ session_write_close();
+ header('Location: ../login');
+ break;
+
default: echo "We could call this a 404 not found... Or what are you doing here?";
}
}
diff --git a/moe/includes/core.php b/moe/includes/core.php
index 59d6d4e..23369a3 100644
--- a/moe/includes/core.php
+++ b/moe/includes/core.php
@@ -1,6 +1,7 @@
<?php
// This file will handle all functions used by Pomf's Moe Panel
-$db = new PDO('mysql:host=127.0.0.1;port=3307;dbname=pomf', 'xxx', 'xxx', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"));
+session_start();
+$db = new PDO('mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=pomf', 'xxx', 'xxx', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"));
function register ($email, $pass) {
global $db;
@@ -16,21 +17,39 @@ function register ($email, $pass) {
$hash = password_hash($pass, PASSWORD_DEFAULT);
$do->bindParam(':pass', $hash);
$do->execute();
+ $_SESSION['id'] = $result['id'];
+ $_SESSION['email'] = $result['email'];
header('Location: api.php?do=cp');
}
}
function login ($email, $pass) {
global $db;
- $do = $db->prepare("SELECT pass FROM accounts WHERE email = (:email)");
+ $do = $db->prepare("SELECT pass, id, email, level FROM accounts WHERE email = (:email)");
$do->bindParam(':email', $email);
$do->execute();
$result = $do->fetch(PDO::FETCH_ASSOC);
if (password_verify($pass, $result['pass'])) {
+ $_SESSION['id'] = $result['id'];
+ $_SESSION['email'] = $result['email'];
+ $_SESSION['level'] = $result['level'];
header('Location: api.php?do=cp');
}else{
header('Location: ../login/index.html#fail');
}
}
-?> \ No newline at end of file
+
+function search ($word) {
+ global $db;
+ $str = "%".$word."%";
+ $do = $db->prepare("SELECT * FROM files WHERE orginalname LIKE (:1) OR filename LIKE (:2) LIMIT 5");
+ $do->bindParam(':1', $str);
+ $do->bindParam(':2', $str);
+ $do->execute();
+
+ while ($row = $do->fetch(PDO::FETCH_ASSOC)) {
+ print $row['orginalname'].' - '.$row['filename'].'<br/>';
+ }
+}
+?>