Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

CodeAmber.org Alerts Script
Welcome, Guest. Please login or register.
November 21, 2008, 10:09:40 AM
11306 Posts in 1249 Topics by 501 Members
Latest Member: rosaline
Experts Round Table Network  |  Bits and Bytes  |  Tips, Tricks, Snippets, Tidbits And General Pearls Of Wisdom  |  CodeAmber.org Alerts Script « previous next »
Pages: [1]
Author Topic: CodeAmber.org Alerts Script  (Read 3626 times)
CrYpTiC_MauleR
Site Builder

Offline Offline

Posts: 489



WWW
« on: March 03, 2007, 08:33:27 PM »

Code
Language: php (GeSHi-highlighted)
<?php
/*
* Copyright (C) 2007 CrYpTiC MauleR <http://www.expertsrt.net/images/cm_email.gif>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*/

//header('Content-Type: text/html');
$update_interval = 1800; /* More Often The Better  (0 Will Disable Caching) */
$cache = 'amber.txt'; /* Where Cached Copy Is Stored For Speedy Display */
 
if ((file_exists($cache)) && (update_interval > (time() - filemtime($cache))))
{
   echo file_get_contents($cache);
}
else
{
   if (false !== ($data = file_get_contents('http://www.codeamber.org/js/alerts.js')))
   {
       $regex = '|/(\w+)/>(?:<b>)?([\w ]+)|i';
       if ((preg_match_all($regex, $data, $match)) && (0 < count($match[1])))
       {
           ob_start();
           $count = count($match[1]);
           echo 'Current Alert';
           if (1 !== $count)
           {
               echo 's';
           }
           echo "<br />\n";
           for ($i = 0; $i < $count; $i++)
           {
               echo "<a href='http://www.codeamber.org/" . $match[1][$i] . "/'>"
                  . $match[2][$i] . "</a><br />\n";
           }
           echo "Powered By :<br />\n"
              . "<a href='http://www.codeamber.org/'>CodeAmber.org</a>\n";
           file_put_contents($cache, ob_get_contents());
           ob_end_flush();
       }
       else
       {
           echo 'No Alerts';
       }
   }
   else
   {
       echo 'Error Getting Alerts';
   }
}
 
?>

This script I made for my now abandoned journal community system. It will grab the contents from the JS file and extract relevant details about the alert and create links back to the page. This way you can display the alerts to people who do not have JS enabled like NoScript users for instance. If I have time I may add the feature to grab any photo from the child's alert page to display along with their alert. Share code and modify as you will. PLEASE if you do so make sure to properly sanitize the external data retrieved as I did in the for() loop, will prevent attacks on your site and also prevent the likelihood that the data may break your layout (its happened before, one reason I added the cleaning).
« Last Edit: May 31, 2007, 12:07:16 PM by CrYpTiC_MauleR » Logged

[x] Fight | www.crypticmauler.com
"You must be
VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #1 on: March 04, 2007, 01:35:38 AM »

interesting. I know a lot more sites that give out this kind of information. I didn't find codeamber.org amongst them (strange and sad).
I don't knw if it's of any interest to you, but here's the links page's link itself http://www.lenet3000.com/enfantsdisparus.html

I couldn't find a contact email to ask them to add codeamber to their list.

If someone interested would parse their output also, the three most "interesting" (technically) links would be http://193.252.228.130/ , http://www.droitsenfant.com/disparition.htm and http://www.childfocus.be/fr/index.php?language=en
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
CrYpTiC_MauleR
Site Builder

Offline Offline

Posts: 489



WWW
« Reply #2 on: March 04, 2007, 04:36:26 PM »

CodeAmber is what is used in the US. Every state if I recall participate in it with local and federal law enforcement to issue an alert when a child is missing due to abduction, kidnapping etc. From the links you gave looks like other countries have similar systems in place.
Logged

[x] Fight | www.crypticmauler.com
"You must be
VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #3 on: March 05, 2007, 12:44:06 PM »

some kind of "aggregator" or "portal" could be nice, as people probably try to cross the borders/frontiers ASAP when they kid-nap some one ;-)
(if not for ***ing and "disposing of" them at once, of course)
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
CrYpTiC_MauleR
Site Builder

Offline Offline

Posts: 489



WWW
« Reply #4 on: May 05, 2007, 04:36:08 PM »

Oddly they now offer XML feeds http://codeamber.org/xml_alerts.html but restrict it, as to why I don't know. Seems illogical to restrict people helping to spread amber alerts.
Logged

[x] Fight | www.crypticmauler.com
"You must be
Pages: [1]
« previous next »
    Jump to: