summaryrefslogtreecommitdiff
path: root/moe/includes/core.php
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/core.php
parentca784b878869279c95deaaadb754f17646e172dc (diff)
it will be ready sometime..
Diffstat (limited to 'moe/includes/core.php')
-rw-r--r--moe/includes/core.php25
1 files changed, 22 insertions, 3 deletions
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/>';
+ }
+}
+?>