mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-12-26 06:40:21 +00:00
Merge pull request #225 from annando/1411-leistungsschutzrecht
Leistungsschutzrecht: A mechanism to avoid problems with a stupid german law
This commit is contained in:
commit
3d8d0e2860
4 changed files with 230 additions and 94 deletions
|
@ -985,7 +985,8 @@ function fbpost_cleanpicture($url) {
|
|||
function fbpost_fetchwall($a, $uid) {
|
||||
require_once("include/oembed.php");
|
||||
require_once("include/network.php");
|
||||
require_once('mod/item.php');
|
||||
require_once("include/items.php");
|
||||
require_once("mod/item.php");
|
||||
|
||||
$access_token = get_pconfig($uid,'facebook','access_token');
|
||||
$post_to_page = get_pconfig($uid,'facebook','post_to_page');
|
||||
|
@ -1043,13 +1044,16 @@ function fbpost_fetchwall($a, $uid) {
|
|||
|
||||
$_REQUEST["body"] = (isset($item->message) ? escape_tags($item->message) : '');
|
||||
|
||||
$pagedata = array();
|
||||
$content = "";
|
||||
$type = "";
|
||||
$pagedata["type"] = "";
|
||||
|
||||
if(isset($item->name) and isset($item->link)) {
|
||||
$item->link = original_url($item->link);
|
||||
$oembed_data = oembed_fetch_url($item->link);
|
||||
$type = $oembed_data->type;
|
||||
$pagedata["type"] = $oembed_data->type;
|
||||
$pagedata["url"] = $item->link;
|
||||
$pagedata["title"] = $item->name;
|
||||
$content = "[bookmark=".$item->link."]".$item->name."[/bookmark]";
|
||||
|
||||
// If a link is not only attached but also added in the body, look if it can be removed in the body.
|
||||
|
@ -1061,75 +1065,71 @@ function fbpost_fetchwall($a, $uid) {
|
|||
} elseif (isset($item->name))
|
||||
$content .= "[b]".$item->name."[/b]";
|
||||
|
||||
$quote = "";
|
||||
$pagedata["text"] = "";
|
||||
if(isset($item->description) and ($item->type != "photo"))
|
||||
$quote = $item->description;
|
||||
$pagedata["text"] = $item->description;
|
||||
|
||||
if(isset($item->caption) and ($item->type == "photo"))
|
||||
$quote = $item->caption;
|
||||
$pagedata["text"] = $item->caption;
|
||||
|
||||
// Only import the picture when the message is no video
|
||||
// oembed display a picture of the video as well
|
||||
//if ($item->type != "video") {
|
||||
//if (($item->type != "video") and ($item->type != "photo")) {
|
||||
if (($type == "") OR ($type == "link")) {
|
||||
if (($pagedata["type"] == "") OR ($pagedata["type"] == "link")) {
|
||||
|
||||
$type = $item->type;
|
||||
$pagedata["type"] = $item->type;
|
||||
|
||||
if (isset($item->picture))
|
||||
$picture = $item->picture;
|
||||
$pagedata["images"][0]["src"] = $item->picture;
|
||||
|
||||
if (($type == "photo") AND isset($item->object_id)) {
|
||||
if (($pagedata["type"] == "photo") AND isset($item->object_id)) {
|
||||
logger('fbpost_fetchwall: fetching fbid '.$item->object_id, LOGGER_DEBUG);
|
||||
$url = "https://graph.facebook.com/".$item->object_id."?access_token=".$access_token;
|
||||
$feed = fetch_url($url);
|
||||
$data = json_decode($feed);
|
||||
if (isset($data->images)) {
|
||||
$picture = $data->images[0]->source;
|
||||
$pagedata["images"][0]["src"] = $data->images[0]->source;
|
||||
logger('fbpost_fetchwall: got fbid image '.$preview, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
if(trim($_REQUEST["body"].$content.$quote) == '') {
|
||||
if(trim($_REQUEST["body"].$content.$pagedata["text"]) == '') {
|
||||
logger('facebook: empty body 2 '.$item->id.' '.print_r($item, true));
|
||||
continue;
|
||||
}
|
||||
|
||||
$picture = fbpost_cleanpicture($picture);
|
||||
$pagedata["images"][0]["src"] = fbpost_cleanpicture($pagedata["images"][0]["src"]);
|
||||
|
||||
if(($picture != "") && isset($item->link)) {
|
||||
if(($pagedata["images"][0]["src"] != "") && isset($item->link)) {
|
||||
$item->link = original_url($item->link);
|
||||
$content .= "\n".'[url='.$item->link.'][img]'.$picture.'[/img][/url]';
|
||||
$pagedata["url"] = $item->link;
|
||||
$content .= "\n".'[url='.$item->link.'][img]'.$pagedata["images"][0]["src"].'[/img][/url]';
|
||||
} else {
|
||||
if ($picture != "")
|
||||
$content .= "\n".'[img]'.$picture.'[/img]';
|
||||
if ($pagedata["images"][0]["src"] != "")
|
||||
$content .= "\n".'[img]'.$pagedata["images"][0]["src"].'[/img]';
|
||||
// if just a link, it may be a wall photo - check
|
||||
if(isset($item->link))
|
||||
$content .= fbpost_get_photo($uid,$item->link);
|
||||
}
|
||||
}
|
||||
|
||||
if(trim($_REQUEST["body"].$content.$quote) == '') {
|
||||
if(trim($_REQUEST["body"].$content.$pagedata["text"]) == '') {
|
||||
logger('facebook: empty body '.$item->id.' '.print_r($item, true));
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($content)
|
||||
$_REQUEST["body"] .= "\n";
|
||||
if ($pagedata["type"] != "")
|
||||
$_REQUEST["body"] .= add_page_info_data($pagedata);
|
||||
else {
|
||||
if ($content)
|
||||
$_REQUEST["body"] .= "\n".trim($content);
|
||||
|
||||
if ($type)
|
||||
$_REQUEST["body"] .= "[class=type-".$type."]";
|
||||
if ($pagedata["text"])
|
||||
$_REQUEST["body"] .= "\n[quote]".$pagedata["text"]."[/quote]";
|
||||
|
||||
if ($content)
|
||||
$_REQUEST["body"] .= trim($content);
|
||||
|
||||
if ($quote)
|
||||
$_REQUEST["body"] .= "\n[quote]".$quote."[/quote]";
|
||||
|
||||
if ($type)
|
||||
$_REQUEST["body"] .= "[/class]";
|
||||
|
||||
$_REQUEST["body"] = trim($_REQUEST["body"]);
|
||||
$_REQUEST["body"] = trim($_REQUEST["body"]);
|
||||
}
|
||||
|
||||
if (isset($item->place)) {
|
||||
if ($item->place->name or $item->place->location->street or
|
||||
|
|
|
@ -217,6 +217,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
|||
|
||||
require_once("include/oembed.php");
|
||||
require_once("include/network.php");
|
||||
require_once("include/items.php");
|
||||
|
||||
// check if it was already imported
|
||||
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
|
||||
|
@ -336,16 +337,19 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
|||
break;
|
||||
}
|
||||
|
||||
$pagedata = array();
|
||||
$content = "";
|
||||
$type = "";
|
||||
$pagedata["type"] = "";
|
||||
|
||||
if (isset($post->attachment->name) and isset($post->attachment->href)) {
|
||||
$post->attachment->href = original_url($post->attachment->href);
|
||||
$oembed_data = oembed_fetch_url($post->attachment->href);
|
||||
$type = $oembed_data->type;
|
||||
if ($type == "rich")
|
||||
$type = "link";
|
||||
$pagedata["type"] = $oembed_data->type;
|
||||
if ($pagedata["type"] == "rich")
|
||||
$pagedata["type"] = "link";
|
||||
|
||||
$pagedata["url"] = $post->attachment->href;
|
||||
$pagedata["title"] = $post->attachment->name;
|
||||
$content = "[bookmark=".$post->attachment->href."]".$post->attachment->name."[/bookmark]";
|
||||
|
||||
// If a link is not only attached but also added in the body, look if it can be removed in the body.
|
||||
|
@ -357,28 +361,28 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
|||
} elseif (isset($post->attachment->name) AND ($post->attachment->name != ""))
|
||||
$content = "[b]" . $post->attachment->name."[/b]";
|
||||
|
||||
$quote = "";
|
||||
$pagedata["text"] = "";
|
||||
if (isset($post->attachment->description) and ($post->attachment->fb_object_type != "photo"))
|
||||
$quote = $post->attachment->description;
|
||||
$pagedata["text"] = $post->attachment->description;
|
||||
|
||||
if (isset($post->attachment->caption) and ($post->attachment->fb_object_type == "photo"))
|
||||
$quote = $post->attachment->caption;
|
||||
$pagedata["text"] = $post->attachment->caption;
|
||||
|
||||
if ($quote.$post->attachment->href.$content.$postarray["body"] == "")
|
||||
if ($pagedata["text"].$post->attachment->href.$content.$postarray["body"] == "")
|
||||
return;
|
||||
|
||||
if (isset($post->attachment->media) AND (($type == "") OR ($type == "link"))) {
|
||||
if (isset($post->attachment->media) AND (($pagedata["type"] == "") OR ($pagedata["type"] == "link"))) {
|
||||
foreach ($post->attachment->media AS $media) {
|
||||
|
||||
if (isset($media->type))
|
||||
$type = $media->type;
|
||||
$pagedata["type"] = $media->type;
|
||||
|
||||
if (isset($media->src))
|
||||
$preview = $media->src;
|
||||
$pagedata["images"][0]["src"] = $media->src;
|
||||
|
||||
if (isset($media->photo)) {
|
||||
if (isset($media->photo->images) AND (count($media->photo->images) > 1))
|
||||
$preview = $media->photo->images[1]->src;
|
||||
$pagedata["images"][0]["src"] = $media->photo->images[1]->src;
|
||||
|
||||
if (isset($media->photo->fbid)) {
|
||||
logger('fbsync_createpost: fetching fbid '.$media->photo->fbid, LOGGER_DEBUG);
|
||||
|
@ -386,20 +390,22 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
|||
$feed = fetch_url($url);
|
||||
$data = json_decode($feed);
|
||||
if (isset($data->images)) {
|
||||
$preview = $data->images[0]->source;
|
||||
logger('fbsync_createpost: got fbid '.$media->photo->fbid.' image '.$preview, LOGGER_DEBUG);
|
||||
$pagedata["images"][0]["src"] = $data->images[0]->source;
|
||||
logger('fbsync_createpost: got fbid '.$media->photo->fbid.' image '.$pagedata["images"][0]["src"], LOGGER_DEBUG);
|
||||
} else
|
||||
logger('fbsync_createpost: error fetching fbid '.$media->photo->fbid.' '.print_r($data, true), LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
$preview = fbpost_cleanpicture($preview);
|
||||
$pagedata["images"][0]["src"] = fbpost_cleanpicture($pagedata["images"][0]["src"]);
|
||||
|
||||
if (isset($media->href) AND ($preview != "") AND ($media->href != ""))
|
||||
$content .= "\n".'[url='.$media->href.'][img]'.$preview.'[/img][/url]';
|
||||
else {
|
||||
if ($preview != "")
|
||||
$content .= "\n".'[img]'.$preview.'[/img]';
|
||||
if (isset($media->href) AND ($pagedata["images"][0]["src"] != "") AND ($media->href != "")) {
|
||||
$media->href = original_url($media->href);
|
||||
$pagedata["url"] = $media->href;
|
||||
$content .= "\n".'[url='.$media->href.'][img]'.$pagedata["images"][0]["src"].'[/img][/url]';
|
||||
} else {
|
||||
if ($pagedata["images"][0]["src"] != "")
|
||||
$content .= "\n".'[img]'.$pagedata["images"][0]["src"].'[/img]';
|
||||
|
||||
// if just a link, it may be a wall photo - check
|
||||
if (isset($post->link))
|
||||
|
@ -408,25 +414,20 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
|||
}
|
||||
}
|
||||
|
||||
if ($type == "link")
|
||||
$postarray["object-type"] = ACTIVITY_OBJ_BOOKMARK;
|
||||
if ($pagedata["type"] != "") {
|
||||
if ($pagedata["type"] == "link")
|
||||
$postarray["object-type"] = ACTIVITY_OBJ_BOOKMARK;
|
||||
|
||||
if ($content)
|
||||
$postarray["body"] .= "\n";
|
||||
$postarray["body"] .= add_page_info_data($pagedata);
|
||||
} else {
|
||||
if ($content)
|
||||
$postarray["body"] .= "\n".trim($content);
|
||||
|
||||
if ($type)
|
||||
$postarray["body"] .= "[class=type-".$type."]";
|
||||
if ($pagedata["text"])
|
||||
$postarray["body"] .= "\n[quote]".trim($pagedata["text"])."[/quote]";
|
||||
|
||||
if ($content)
|
||||
$postarray["body"] .= trim($content);
|
||||
|
||||
if ($quote)
|
||||
$postarray["body"] .= "\n[quote]".trim($quote)."[/quote]";
|
||||
|
||||
if ($type)
|
||||
$postarray["body"] .= "[/class]";
|
||||
|
||||
$postarray["body"] = trim($postarray["body"]);
|
||||
$postarray["body"] = trim($postarray["body"]);
|
||||
}
|
||||
|
||||
if (trim($postarray["body"]) == "")
|
||||
return;
|
||||
|
|
|
@ -275,29 +275,35 @@ function fromgplus_cleantext($text) {
|
|||
|
||||
function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
|
||||
require_once("include/Photo.php");
|
||||
require_once("include/items.php");
|
||||
|
||||
$post = "";
|
||||
$quote = "";
|
||||
$type = "";
|
||||
$pagedata = array();
|
||||
$pagedata["type"] = "";
|
||||
|
||||
foreach ($item->object->attachments as $attachment) {
|
||||
switch($attachment->objectType) {
|
||||
case "video":
|
||||
$post .= "\n[class=type-video][bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n[/class]";
|
||||
$pagedata["type"] = "video";
|
||||
$pagedata["url"] = $attachment->url;
|
||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||
break;
|
||||
|
||||
case "article":
|
||||
$post .= "\n[class=type-link][bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
|
||||
$pagedata["type"] = "link";
|
||||
$pagedata["url"] = $attachment->url;
|
||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||
|
||||
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
||||
if ($images["full"] != "")
|
||||
$post .= "\n[img]".$images["full"]."[/img]";
|
||||
$pagedata["images"][0]["src"] = $images["full"];
|
||||
|
||||
$quote = trim(fromgplus_html2bbcode($attachment->content));
|
||||
if ($quote != "")
|
||||
$quote = "\n[quote]".$quote."[/quote]";
|
||||
|
||||
$quote .= "[/class]";
|
||||
if ($quote != "")
|
||||
$pagedata["text"] = $quote;
|
||||
|
||||
break;
|
||||
|
||||
case "photo":
|
||||
|
@ -311,52 +317,72 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
|
|||
$images = store_photo($a, $uid, "", $attachment->image->url);
|
||||
}
|
||||
|
||||
if ($images["preview"] != "")
|
||||
if ($images["preview"] != "") {
|
||||
$post .= "\n[url=".$images["page"]."][img]".$images["preview"]."[/img][/url]\n";
|
||||
elseif ($images["full"] != "")
|
||||
$pagedata["images"][0]["src"] = $images["preview"];
|
||||
$pagedata["url"] = $images["page"];
|
||||
} elseif ($images["full"] != "") {
|
||||
$post .= "\n[img]".$images["full"]."[/img]\n";
|
||||
$pagedata["images"][0]["src"] = $images["full"];
|
||||
|
||||
if (($attachment->displayName != "") AND (fromgplus_cleantext($attachment->displayName) != fromgplus_cleantext($displaytext)))
|
||||
if ($images["preview"] != "")
|
||||
$pagedata["images"][1]["src"] = $images["preview"];
|
||||
}
|
||||
|
||||
if (($attachment->displayName != "") AND (fromgplus_cleantext($attachment->displayName) != fromgplus_cleantext($displaytext))) {
|
||||
$post .= fromgplus_html2bbcode($attachment->displayName)."\n";
|
||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||
}
|
||||
break;
|
||||
|
||||
case "photo-album":
|
||||
$pagedata["url"] = $attachment->url;
|
||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||
$post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
|
||||
|
||||
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
||||
if ($images["preview"] != "")
|
||||
$post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
|
||||
elseif ($images["full"] != "")
|
||||
$post .= "\n[img]".$images["full"]."[/img]\n";
|
||||
|
||||
if ($images["preview"] != "") {
|
||||
$post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
|
||||
$pagedata["images"][0]["src"] = $images["preview"];
|
||||
$pagedata["url"] = $images["full"];
|
||||
} elseif ($images["full"] != "") {
|
||||
$post .= "\n[img]".$images["full"]."[/img]\n";
|
||||
$pagedata["images"][0]["src"] = $images["full"];
|
||||
|
||||
if ($images["preview"] != "")
|
||||
$pagedata["images"][1]["src"] = $images["preview"];
|
||||
}
|
||||
break;
|
||||
|
||||
case "album":
|
||||
$post .= "\n[class=type-link][bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]";
|
||||
$pagedata["type"] = "link";
|
||||
$pagedata["url"] = $attachment->url;
|
||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||
|
||||
$thumb = $attachment->thumbnails[0];
|
||||
$post .= "\n[img]".$thumb->image->url."[/img]";
|
||||
$pagedata["images"][0]["src"] = $thumb->image->url;
|
||||
|
||||
$quote = trim(fromgplus_html2bbcode($thumb->description));
|
||||
if ($quote != "")
|
||||
$quote = "\n[quote]".$quote."[/quote]";
|
||||
$pagedata["text"] = $quote;
|
||||
|
||||
//foreach($attachment->thumbnails as $thumb) {
|
||||
// $preview = "/w".$thumb->image->width."-h".$thumb->image->height."/";
|
||||
// $preview2 = "/w".$thumb->image->width."-h".$thumb->image->height."-p/";
|
||||
// $image = str_replace(array($preview, $preview2), array("/", "/"), $thumb->image->url);
|
||||
|
||||
// $post .= "\n[url=".$thumb->url."][img]".$image."[/img][/url]\n";
|
||||
//}
|
||||
$quote .= "[/class]";
|
||||
break;
|
||||
|
||||
case "audio":
|
||||
$post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
|
||||
$pagedata["url"] = $attachment->url;
|
||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||
$post .= "\n\n[bookmark=".$pagedata["url"]."]".$pagedata["title"]."[/bookmark]\n";
|
||||
break;
|
||||
|
||||
//default:
|
||||
// die($attachment->objectType);
|
||||
}
|
||||
}
|
||||
|
||||
if ($pagedata["type"] != "")
|
||||
return(add_page_info_data($pagedata));
|
||||
|
||||
return($post.$quote);
|
||||
}
|
||||
|
||||
|
|
109
leistungsschutzrecht/leistungsschutzrecht.php
Normal file
109
leistungsschutzrecht/leistungsschutzrecht.php
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: Leistungsschutzrecht
|
||||
* Description: Only useful in germany: Remove data from snippets from members of the VG Media
|
||||
* Version: 0.1
|
||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||
*/
|
||||
|
||||
function leistungsschutzrecht_install() {
|
||||
register_hook('cron', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_cron');
|
||||
register_hook('getsiteinfo', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_getsiteinfo');
|
||||
register_hook('page_info_data', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_getsiteinfo');
|
||||
}
|
||||
|
||||
|
||||
function leistungsschutzrecht_uninstall() {
|
||||
unregister_hook('cron', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_cron');
|
||||
unregister_hook('getsiteinfo', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_getsiteinfo');
|
||||
unregister_hook('page_info_data', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_getsiteinfo');
|
||||
}
|
||||
|
||||
function leistungsschutzrecht_getsiteinfo($a, &$siteinfo) {
|
||||
if (!isset($siteinfo["url"]))
|
||||
return;
|
||||
|
||||
if (!leistungsschutzrecht_is_member_site($siteinfo["url"]))
|
||||
return;
|
||||
|
||||
$siteinfo["title"] = $siteinfo["url"];
|
||||
unset($siteinfo["text"]);
|
||||
unset($siteinfo["image"]);
|
||||
unset($siteinfo["images"]);
|
||||
unset($siteinfo["keywords"]);
|
||||
}
|
||||
|
||||
function leistungsschutzrecht_fetchsites() {
|
||||
require_once("include/network.php");
|
||||
|
||||
$sites = array();
|
||||
|
||||
$url = "http://www.vg-media.de/lizenzen/digitale-verlegerische-angebote/wahrnehmungsberechtigte-digitale-verlegerische-angebote.html";
|
||||
|
||||
$site = fetch_url($url);
|
||||
|
||||
$doc = new DOMDocument();
|
||||
@$doc->loadHTML($site);
|
||||
|
||||
$xpath = new DomXPath($doc);
|
||||
$list = $xpath->query("//td/a");
|
||||
foreach ($list as $node) {
|
||||
$attr = array();
|
||||
if ($node->attributes->length)
|
||||
foreach ($node->attributes as $attribute)
|
||||
$attr[$attribute->name] = $attribute->value;
|
||||
|
||||
if (isset($attr["href"])) {
|
||||
$urldata = parse_url($attr["href"]);
|
||||
|
||||
if (isset($urldata["host"]) AND !isset($urldata["path"])) {
|
||||
$cleanedurlpart = explode("%", $urldata["host"]);
|
||||
|
||||
$hostname = explode(".", $cleanedurlpart[0]);
|
||||
$site = $hostname[sizeof($hostname) - 2].".".$hostname[sizeof($hostname) - 1];
|
||||
$sites[$site] = $site;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($sites)) {
|
||||
set_config('leistungsschutzrecht','sites',$sites);
|
||||
}
|
||||
}
|
||||
|
||||
function leistungsschutzrecht_is_member_site($url) {
|
||||
$sites = get_config('leistungsschutzrecht','sites');
|
||||
|
||||
if ($sites == "")
|
||||
return(false);
|
||||
|
||||
if (sizeof($sites) == 0)
|
||||
return(false);
|
||||
|
||||
$urldata = parse_url($url);
|
||||
|
||||
if (!isset($urldata["host"]))
|
||||
return(false);
|
||||
|
||||
$cleanedurlpart = explode("%", $urldata["host"]);
|
||||
|
||||
$hostname = explode(".", $cleanedurlpart[0]);
|
||||
$site = $hostname[sizeof($hostname) - 2].".".$hostname[sizeof($hostname) - 1];
|
||||
|
||||
return (isset($sites[$site]));
|
||||
}
|
||||
|
||||
function leistungsschutzrecht_cron($a,$b) {
|
||||
$last = get_config('leistungsschutzrecht','last_poll');
|
||||
|
||||
if($last) {
|
||||
$next = $last + 86400;
|
||||
if($next > time()) {
|
||||
logger('poll intervall not reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
leistungsschutzrecht_fetchsites();
|
||||
set_config('leistungsschutzrecht','last_poll', time());
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue