×
https://dev5.netsupport24.net/CN/07_output-client/5.07/apiLatestNewsRadius.CN.php?location=Pirna&radius=5 */ if ( isset($_REQUEST["debug"]) && (int)$_REQUEST["debug"]===1){ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $runtime["debug"]=1; } else{ error_reporting(0); } // define some VARs $fn = 'apiLatestNewsRadius.CN'; $server_group_1 = array( "dev14.netsupport24.net", "beta14.netsupport24.net", "www14.netsupport24.net", "dev15.netsupport24.net", "beta15.netsupport24.net", "www15.netsupport24.net", "dev23.netsupport24.net", "beta23.netsupport24.net", "www23.netsupport24.net", "dev24.netsupport24.net", "beta24.netsupport24.net", "www24.netsupport24.net" ); $server_group_2 = array( "dev5.netsupport24.net", "beta5.netsupport24.net", "www5.netsupport24.net" ); if ( isset($_SERVER['SERVER_NAME']) && in_array($_SERVER['SERVER_NAME'], $server_group_1)){ $version = str_replace( dirname(__DIR__,1).'/', '', __DIR__); $path = array( 'root' => dirname(__DIR__, 2), 'data' => dirname(__DIR__, 5).'/_data/CN', 'cache' => dirname(__DIR__, 5).'/_data/CN/5.19/cache', // /var/www/clients/client4/web3/web/_data/CN/5.19/cache/ 'script' => __DIR__ ); } elseif ( isset($_SERVER['SERVER_NAME']) && in_array($_SERVER['SERVER_NAME'], $server_group_2)){ $path["data"]='/var/customers/webs/webmDSS/netsupport24.net/_data/CN'; // DOCUMENT_ROOT -> /var/customers/webs/webmDSS/netsupport24.net/web-dev/ $path['cache'] = dirname(__DIR__, 5).'/_data/CN/5.19/cache'; // /var/www/clients/client4/web3/web/_data/CN/5.19/cache/ $path["root"]='/var/customers/webs/webmDSS/netsupport24.net/web-dev/CN'; $path["script"]=$path["root"].'/07_output-client/5.09'; } else{ die(""); } $limit=15; // speed: 1000/90sec $time_start = microtime(true); if (!isset($runtime)) $runtime = array(); $global = array( "debug" => TRUE, 'debug_allowed' => array(0,1), "FileNameLength" => 12, "allowed_format" => array("html","json","text", "none"), "format_default" => 'html', "CachePath" => $path['cache'], ); $location = array(); $tags = array(); $tag_ids = array(); $includes = array( $path["data"]."/5.19/config/config_database_external.inc.php", $path["root"]."/00_resources/inq.modules/6.01/global.inc.php", $path["root"]."/00_resources/inq.modules/6.01/array/array.inc.php", $path["root"]."/00_resources/inq.modules/6.01/cache/cache.inc.php", $path["root"]."/00_resources/inq.modules/6.01/database/mysql8.php", $path["root"]."/00_resources/inq.modules/6.01/file/func.file.php", $path["root"]."/00_resources/inq.modules/6.01/json/json.inc.php", ); // DO THE INLUDES foreach($includes as $inc){ if ( $runtime["debug"]===1 ) { // print "\n \$global".var_dump($global); print "\n ... load ".$inc; } if (!include_once($inc)) { print "
";
        if ( $runtime["debug"]===1 ) print "\n... load ".$inc;
        die("FATAL ERROR: could not load file: ".$inc);
    }
}

// correct some VARs
$global["debug"]=TRUE; //--> overwritte the value from /global.inc.php
$timestamp=time();


notify_add($fn." started -------------------------------");

// manage some incoming VARs
( isset($_REQUEST["location"]) && $_REQUEST["location"]!="" ) ? $location['in'] = $_REQUEST["location"] : die("FATAL ERROR: Missing incoming VAR") ;
( isset($_REQUEST["radius"]) && $_REQUEST["radius"]!="" && (int)$_REQUEST["radius"]>0 ) ? $radius = (int)$_REQUEST["radius"] : $radius=5;
( isset($_REQUEST["limit"]) && $_REQUEST["limit"]!="" && (int)$_REQUEST["limit"]>0 ) ? $limit = (int)$_REQUEST["limit"] : $limit=5;
( isset($_REQUEST["debug"]) && (int)$_REQUEST["debug"]===1 && $global["debug"]===TRUE ) ? $runtime["debug"]=1 : $runtime["debug"]=0;
( isset($_REQUEST["publisher_id"]) && (int)$_REQUEST["publisher_id"]>1  ) ? $q_add_publisher="AND publisher_id=".(int)$_REQUEST["publisher_id"]." " : $q_add_publisher = "";
( isset($_REQUEST["picture"]) && (int)$_REQUEST["picture"]>0  ) ? $q_add_picture=' AND story_thumb<>""': $q_add_picture = '';
( isset($_REQUEST["format"]) && in_array($_REQUEST["format"],$global["allowed_format"])  ) ? $runtime["format"]=$_REQUEST["format"] : $runtime["format"]=$global["format_default"];

// Try to return recent cached value
require_once __DIR__."/classes/InqCache.php";
$cache = new InqCache();
$cached = $cache->get(1800);
if ($runtime['format'] == 'json') {
    if ($cached) {
        echo json_response($cached, 200);
        die();
    }
} else {
    if ($cached) die($cached);
}


    if ($runtime["debug"]===1){ notify_add($fn.' ... started'); }

if ( createDBConnection() ) notify_add("Connected to database");
else{
    if ( $runtime["debug"]===1){      }
    else{
        // version 2
        header($_SERVER["SERVER_PROTOCOL"]." 503 Service Temporarily Unavailable", true, 503);      //Service Temporarily Unavailable status code to the client.
        $retryAfterSeconds = 240;                                                                   //The number of seconds that the client should wait before retrying.
        header('Retry-After: ' . $retryAfterSeconds);                                               //Send a Retry-After header to the client.
        echo '

503 Service Temporarily Unavailable

'; //Send a message to the browser so that the user knows what is going on. echo '

Our site is currently under maintenance. (db)

'; exit; //Kill the PHP script. } // die("fatal error"); } // get location (lon/lat) for the given cityname $api_master = "https://api.geo.inquence.com/api/v1/location?q={KEYWORD}&country=DE"; $api_url = str_replace("{KEYWORD}", $location['in'], $api_master ); // $location['details'] = callJSONAPI($api_url,TRUE,84000); $location['details'] = callJSONAPI2($api_url,TRUE,10,2,1,"curl"); if ( $location['details']===FALSE ){ die(""); } if ($runtime["debug"]===1) { $msg = "JSON call to '".$api_url."' finished"; notify_add($fn.$msg); print "\n"; // notify_print(); // closeDBConnection(); // die($fn." die in line 124"); } // $location['details']['data']['lon'] // $location['details']['data']['lat'] if ( !isset($location['details']['data']['lon']) || $location['details']['data']['lon']=="" || !isset( $location['details']['data']['lat'] ) || $location['details']['data']['lat']=="" ){ if ($runtime["debug"]===1){ print "\nlon: ".$location['details']['data']['lon']; print "\nlat: ".$location['details']['data']['lat']."\n"; var_dump($location['details']); } closeDBConnection(); die(""); } // get all tags ids $limit_tags = 500; $query_master = 'SELECT tag_id, ( 3959 * acos ( cos ( radians({LAT}) ) * cos( radians( lat ) ) * cos( radians( lon ) - radians({LON}) ) + sin ( radians({LAT}) ) * sin( radians( lat ) ) ) ) AS distance FROM dug_tags_location HAVING distance < {RADIUS} ORDER BY distance LIMIT 0 , '.$limit_tags.';'; $query = str_replace( array('{LON}','{LAT}','{RADIUS}', '{LIMIT}'), array( $location['details']['data']['lon'], $location['details']['data']['lat'], $radius, $limit_tags ), $query_master ); if ( $runtime["debug"]===1 ) { notify_add($fn.$query); } $tags = executeQuery($query); if ( !isset($tags) || !is_array($tags) || count($tags)<1 ){ closeDBConnection(); die(""); } if ($runtime["debug"]===1) { $msg = "... loaded tags from database"; notify_add($fn . $msg); } // find all articles (max. 5 days) for each tag-id foreach ($tags as $tag){ $tag_ids[] = $tag['tag_id']; } // $tag_time_max = $timestamp-(86400*3); // if ( $q_add_publisher!="" ) $tag_time_max = $timestamp-(86400*30); // $query = 'SELECT * FROM dug_stories_tags WHERE tag_id IN (' . implode(',',$tag_ids) . ') AND tag_time > '.$tag_time_max.' ORDER BY tag_time LIMIT 400;'; $query = 'SELECT * FROM dug_stories_tags WHERE tag_id IN (' . implode(',',$tag_ids) . ') /* ORDER BY tag_time LIMIT 200; */'; if ( $runtime["debug"]===1 ) { print "
\n".$query; }
$story_ids = executeQuery($query);

if ($runtime["debug"]===1) {     $msg = "... loaded story_ids from database";     notify_add($fn . $msg); }


// load blacklist domains
$path['config'] = str_replace('/cache', '/config', $path['cache']);
$runtime['blacklist_source'] = $path['config'].'/LSRblacklist.txt';
$runtime['blacklist_array'] = file($runtime['blacklist_source'], FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
if ( isset($runtime['blacklist_array']) && is_array($runtime['blacklist_array']) && count($runtime['blacklist_array'])>0 ){
    $q_add_lsrdomain = ' AND domain NOT IN ("' . implode('", "', $runtime['blacklist_array']) . '")';
} else{ $q_add_lsrdomain=''; }



// load articles details
$article_ids = array();
$story_time_max = $timestamp-(86400*10);
foreach( $story_ids as $story_id){ $article_ids[] = $story_id['story_id']; }
// $query = 'SELECT * FROM dug_stories WHERE story_id IN (' . implode(',',$article_ids) . ')';
$query = 'SELECT story_id, story_title, story_time, story_thumb, story_desc FROM dug_stories WHERE story_id IN (' . implode(',',$article_ids) . ') AND story_time>'.$story_time_max.'
AND processing>79 '.$q_add_lsrdomain . $q_add_picture.' AND story_cat<>100 '.$q_add_publisher.' ORDER BY story_time DESC LIMIT 0,'.$limit;
    if ( $runtime["debug"]===1 ) { print "
\n".$query; }
$news = executeQuery($query);

// create a fallback for to less articles
if ( !isset($news) || !is_array($news) || count($news)<$limit){
    $story_time_max = $timestamp-(86400*60);
    foreach( $story_ids as $story_id){ $article_ids[] = $story_id['story_id']; }
// $query = 'SELECT * FROM dug_stories WHERE story_id IN (' . implode(',',$article_ids) . ')';
    $query = 'SELECT story_id, story_title, story_time, story_thumb, story_desc FROM dug_stories WHERE story_id IN (' . implode(',',$article_ids) . ') AND story_time>'.$story_time_max.'
AND processing>79 '.$q_add_picture. $q_add_lsrdomain . ' AND story_cat<>100 '.$q_add_publisher.' ORDER BY story_time DESC LIMIT 0,'.$limit;
    if ( $runtime["debug"]===1 ) { print "
\n".$query; }
    $news = executeQuery($query);
}



// create output
if ( !isset($news) || !is_array($news) || count($news)<1 ){
    if ( $runtime["format"]==='json' ){ http_response_code(500); closeDBConnection(); die();  }
    closeDBConnection();
    die(''); // no stories found
}

// deal with data
$i = -1; $i_max=count($news)-1;
while ( $i++<$i_max){
    if ( isset($q_add_publisher) && $q_add_publisher!="" ){ // special case "dpa"
        $news[$i]['story_url'] = 'https://www.hier-aktuell.de/artikel/'.$news[$i]['story_id'];
    }
}



$links=array(); $i=0;
if ( $runtime["format"]=='json' ){
    $cache->set($news);
    echo json_response($news, 200);
    closeDBConnection();
    die();
}


// (B) HTML OUTPUT
$template = file_get_contents('template_LatestNews.html'); // needs {HEADLINE} & {LINKS}
// $links_master = '
  • {STORY_TITLE}
  • '; $links_master_internal = '
  • {STORY_TITLE}
  • '; $links_master_external = '
  • {STORY_TITLE}
  • '; if ($runtime["debug"]===1){ $links_master_internal = '
  • {STORY_TITLE}
  • '; } foreach( $news as $article ){ if ($i++>=$limit) continue; if ( isset($article['story_url']) && $article['story_url']!="" ) $links_master = $links_master_external; else { $article['story_url']=''; $links_master = $links_master_internal; } $links[] = str_replace( array('{STORY_ID}','{STORY_TITLE}','{STORY_THUMB}', '{STORY_URL}'), array( $article['story_id'], $article['story_title'], $article['story_thumb'], $article['story_url']), $links_master ); } if ( $radius <= 5){ $headline = 'Nachrichten aus '.$location['in']; } else{ $headline = $location['in'].' und Umgebung'; } $output = str_replace( array( '{HEADLINE}', '{LINKS}'), array( $headline, implode("\n", $links)), $template); if ( $runtime["debug"]===0 ){ $output = preg_replace('//Uis', '', $output); // remove all comments in public html } closeDBConnection(); if ($output) { $cache->set($output); die($output); } else { die($cache->get() ?: ''); } // merge & order this data // generate the output $output = array( 'status' => 'ok', 'content' => $data, ); // $output = json_encode($output, TRUE); $output = json_encode($output, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); header('Access-Control-Allow-Origin: *'); header("Content-type: application/json; charset=utf-8"); print $output; closeDBConnection(); die();
    -Anzeige-

    Nachrichten aus Herten

    Herten-Wetter

    06:49 Uhr
    Samstag, 1. Oktober 2022
    Bedeckt
    max 12°C min 10,4°C
    Luftfeuchtigkeit: 94 %
    Wind: 5,81 km/h
    -Anzeige-

    guetsel.de

    Herten, leise und umweltschonend, neue Abfallsammelfahrzeuge fahren mit Wasserstoff

    Wasserstoff, Abfallsammelfahrzeuge, Gütsel, Herten Güts... ... mehr ... 1. Oktober 2022

    waltroper-zeitung.de

    Wieder wird es dreistellig: Hertener Löwen legen gegen UBC Münster II nach

    Löwen, Zeitung, Hertener, Münster, Waltroper Waltroper Ze... ... mehr ... 30. September 2022

    hertener-allgemeine.de

    HA+ Wieder wird es dreistellig: Hertener Löwen legen gegen UBC Münster II nach

    Hertener, Münster, Löwen, Allgemeine Hertener... ... mehr ... 30. September 2022

    hertener-allgemeine.de

    Menschenkette in der Hertener Innenstadt gibt Mut und Kraft gegen Krieg und Gewalt

    Hertener, Menschenkette, Mut, Innenstadt, Allgemeine, Gewalt, Krieg, Kraft Herten... ... mehr ... 30. September 2022

    -Anzeige-
    -Anzeige-

    politik

    -Anzeige-

    wirtschaft

    -Anzeige-

    kultur

    radiovest.de

    Prozess um Drogenküche in Herten: Revision möglich

    Drogenküche, Prozess, Vest, Revision, Radio, Herten ... mehr ... 26. September 2022

    stimberg-zeitung.de

    Konzert Herten: Dust n'Bones sind ganz nah am Original

    Zeitung, Konzert, Original, Bones, Dust, Stimberg, Herten ... mehr ... 26. September 2022

    radiovest.de

    Räuberpärchen nach Flucht durch Emscher in U-Haft

    Vest, Emscher, Flucht, Haft, Räuberpärchen, Radio, Herten ... mehr ... 26. September 2022

    hertener-allgemeine.de

    Konzert in Herten: DSDS-Star singt Hits von Udo Jürgens

    Allgemeine, Hits, Hertener, Konzert, Star, Jürgens, Udo, Herten ... mehr ... 22. September 2022

    radiovest.de

    Wichtige Hauptstraße in Herten gesperrt

    Hauptstraße, Vest, Wichtige, Radio, Herten ... mehr ... 21. September 2022

    hertener-allgemeine.de

    Beim interkulturellen Stadtfest tanzt sogar der Bürgermeister

    Allgemeine, Hertener, Bürgermeister, Stadtfest, Herten ... mehr ... 19. September 2022

    -Anzeige-

    sport

    -Anzeige-

    panorama

    technik

    wissen

    reise

    expand_less