-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.php
executable file
·65 lines (59 loc) · 2.35 KB
/
process.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
<?php // Ajax processing
include("inc/dbconnect.php");
if ($_POST['event'] == "email") { // Process form
$receiver = "[email protected]";
$type = $_POST['contact-type'];
if ($type == "message") $type = "message"; // Check which radio-buttin was selected
else $type = "tip";
$subject = "New $type from sketch-tips";
$name = $_POST['name'];
$email = $_POST['email'];
$msg = $_POST['msg'];
$mailheader = "From: $name<$email>";
mail($receiver, $subject, $msg, $mailheader) or die("Fehler");
echo "Thanks for getting in contact. I will come back to you as soon as possible.";
}
if ($_POST['event'] == "loadmore") { // If loadmore-link was clicked
$start = $_POST['start']; // From which tip to start (that is, how many were already shown)
$count = $_POST['count']; // How many tips to load
$ergebnis = mysql_query("SELECT * FROM articles LIMIT $start, $count");
$anzahl = mysql_num_rows($ergebnis);
while ($row = mysql_fetch_object($ergebnis)) {
$date = $row->date;
$title = $row->title;
$text = $row->text;
$timestamp = strtotime($row->date);
$date = strftime("%B <span class=\"tip-date-day\">%d</span>", $timestamp);
$datetime = strftime("%Y-%m-%d", $timestamp);
$faded = true;
include("inc/article.php");
}
}
if ($_POST['event'] == "tipscount") { // Get total number of tips
$ergebnis = mysql_query("SELECT * FROM articles");
$anzahl = mysql_num_rows($ergebnis);
echo $anzahl;
}
if ($_POST['event'] == "searchcount") { // Get number of tips with given search term
$term = $_POST['searchterm'];
$ergebnis = mysql_query("SELECT * FROM articles WHERE text LIKE '%$term%' || title LIKE '%$term%'");
$anzahl = mysql_num_rows($ergebnis);
echo $anzahl;
}
if ($_POST['event'] == "search") { // Get tips with given search term
$term = $_POST['searchterm'];
$ergebnis = mysql_query("SELECT * FROM articles WHERE text LIKE '%$term%' || title LIKE '%$term%' LIMIT 2");
while ($row = mysql_fetch_object($ergebnis)) {
$date = $row->date;
$title = $row->title;
$title = str_ireplace($term, '<mark>'.$term.'</mark>', $title); // Highlight words
$text = $row->text;
$text = str_ireplace($term, '<mark>'.$term.'</mark>', $text); // Highlight words
$timestamp = strtotime($row->date);
$date = strftime("%B <span class=\"tip-date-day\">%d</span>", $timestamp);
$datetime = strftime("%Y-%m-%d", $timestamp);
$faded = true;
include("inc/article.php");
}
}
?>