-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmod_quote.php
74 lines (56 loc) · 2.29 KB
/
mod_quote.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
function addquote($args) {
if(strlen($args)>450) {
return "[quote] Deze quote is te lang!";
} else {
include("sqlconfig.php");
$dbh = new PDO('mysql:host=localhost;dbname='.$db,$user,$pass,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$query = $dbh->prepare("INSERT INTO quote(id,quote) VALUES (0,:quote) ");
$query->bindParam(':quote',$args,PDO::PARAM_STR);
$query->execute();
return "[quote] Quote toegevoegd (#".$dbh->lastInsertId().")";
}
}
function delquote($args) {
include("sqlconfig.php");
$dbh = new PDO('mysql:host=localhost;dbname='.$db,$user,$pass,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
if(getquote($args) == "[quote] Geen quote gevonden met dit ID") {
return "[quote] Deze quote bestaat helemaal niet!";
} else {
$query = $dbh->prepare("DELETE FROM quote WHERE id=:id");
}
$query->bindParam(':id',$args,PDO::PARAM_STR);
$query->execute();
return "[quote] Quote verwijderd";
}
function quote($args) {
include("sqlconfig.php");
$dbh = new PDO('mysql:host=localhost;dbname='.$db,$user,$pass,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
if(!empty($args)) {
$args = "%$args%";
$query = $dbh->prepare("SELECT * FROM quote WHERE quote LIKE :search ORDER BY RAND() LIMIT 0,1");
$query->bindParam('search',$args,PDO::PARAM_STR);
} else {
$query = $dbh->prepare("SELECT * FROM quote ORDER BY RAND() LIMIT 0,1");
}
$query->execute();
if($query->rowCount() > 0) {
$result = $query->fetch(PDO::FETCH_ASSOC);
return "[quote] #".$result['id']." ".$result['quote'];
} else {
return "[quote] Geen quotes gevonden, voeg er eentje toe met 'quote+'";
}
}
function getquote($args) {
include("sqlconfig.php");
$dbh = new PDO('mysql:host=localhost;dbname='.$db,$user,$pass,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$query = $dbh->prepare("SELECT quote FROM quote WHERE id=:id");
$query->bindParam(':id',$args,PDO::PARAM_STR);
$query->execute();
if($query->rowCount() > 0) {
$quote = $query->fetchColumn();
return "[quote] #".$args." ".$quote;
} else {
return "[quote] Geen quote gevonden met dit ID";
}
}