Permalink
Browse files

#18 Dit zou het beter moeten fixen

  • Loading branch information...
thunderbug committed Oct 3, 2017
1 parent 692f8ae commit 3bae7d744f312fc6eff6ca7a5184a529061daa78
Showing with 23 additions and 24 deletions.
  1. +23 −24 cron.php
View
@@ -17,7 +17,7 @@
);
//Get max date from posts-table
$lastDate = strtotime($database->max("posts","time"));
$lastDate = strtotime($database->max("posts", "time"));
//Request feed from facebook
$data = fetchUrl("https://graph.facebook.com/" . $fbGroupID . "/feed?limit=100&fields=from,message,updated_time,id&since=" . $lastDate . "&access_token=" . $appID . "|" . $appSecret);
@@ -48,9 +48,6 @@
$row["regex"] = str_replace("sint", "(st\.?|sint)", $row["regex"]);
}
//Check for "de" "het" "een" in a sentence
$row["regex"] = "(^(?!de|het|een).*) ".$row["regex"];
checkNameinText($row, $postData);
}
}
@@ -75,26 +72,28 @@ function checkNameinText($cityData, $postData)
{
global $database, $blacklist;
if ( preg_match("~\b" . strtolower($cityData["regex"]) . "\b~", strtolower($postData["message"])) > 0 ) {
if ( !is_array($blacklist) || $postData["message"] === str_replace( $blacklist, "", $postData["message"] ) ) {
$id = explode("_", $postData["id"]);
$count = $database->count("posts", array("postID" => $id[1], "gemeente" => $cityData["name"], "zipcode" => $cityData["zipcode"]));
if ($count == 0) {
$database->insert("posts", array(
"zipcode" => $cityData["zipcode"],
"gemeente" => $cityData["name"],
"postID" => $id[1],
"time" => date("Y-m-d H:i:s", strtotime($postData["updated_time"])),
"text" => $postData["message"],
"auteur" => $postData["from"]["name"]
));
} else {
$database->update("posts",
array("text" => $postData["message"], "auteur" => $postData["from"]["name"], "time" => date("Y-m-d H:i:s", strtotime($postData["updated_time"]))),
array("postID" => $id[1], "gemeente" => $cityData["name"], "zipcode" => $cityData["zipcode"])
);
if (preg_match("~\b" . strtolower($cityData["regex"]) . "\b~", strtolower($postData["message"])) > 0) {
if (preg_match("/(de|het|een) " . strtolower($cityData["regex"]) . "/", strtolower($postData["message"])) == 0) {
if (!is_array($blacklist) || $postData["message"] === str_replace($blacklist, "", $postData["message"])) {
$id = explode("_", $postData["id"]);
$count = $database->count("posts", array("postID" => $id[1], "gemeente" => $cityData["name"], "zipcode" => $cityData["zipcode"]));
if ($count == 0) {
$database->insert("posts", array(
"zipcode" => $cityData["zipcode"],
"gemeente" => $cityData["name"],
"postID" => $id[1],
"time" => date("Y-m-d H:i:s", strtotime($postData["updated_time"])),
"text" => $postData["message"],
"auteur" => $postData["from"]["name"]
));
} else {
$database->update("posts",
array("text" => $postData["message"], "auteur" => $postData["from"]["name"], "time" => date("Y-m-d H:i:s", strtotime($postData["updated_time"]))),
array("postID" => $id[1], "gemeente" => $cityData["name"], "zipcode" => $cityData["zipcode"])
);
}
}
}
}

2 comments on commit 3bae7d7

@futtta

This comment has been minimized.

Show comment
Hide comment
@futtta

futtta Oct 4, 2017

Owner

zou idd de job moeten doen :-)

al getest/ live gezet?

Owner

futtta replied Oct 4, 2017

zou idd de job moeten doen :-)

al getest/ live gezet?

@thunderbug

This comment has been minimized.

Show comment
Hide comment
@thunderbug

thunderbug Oct 4, 2017

Collaborator

Ziezo alles is getest en live gezet :)

Collaborator

thunderbug replied Oct 4, 2017

Ziezo alles is getest en live gezet :)

Please sign in to comment.