NATION

PASSWORD

Nutcracker discontinued

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.
User avatar
Letoilenoir
Chargé d'Affaires
 
Posts: 424
Founded: Nov 26, 2010
Ex-Nation

Nutcracker discontinued

Postby Letoilenoir » Wed Jun 24, 2015 3:10 pm

Letoilenoir wrote:Courtesy of The Red Fleet N.U.T.Cracker


Just a heads up to those of you who have found the Pipes tool above useful, Yahoo is dropping pipes from 25th September 2015 so this method of finding update times will no longer be available in this form

I may get around to coding a more permanent solution if there is a demand but in the meantime I hope that it has helped and thank those who have employed it since its inception
KEEP THE BLOOD CAVE FREE

User avatar
Ever-Wandering Souls
Negotiator
 
Posts: 7267
Founded: Jan 01, 2014
Father Knows Best State

Postby Ever-Wandering Souls » Wed Jun 24, 2015 6:05 pm

I grew up in raiding using pipes :) Still used them to find an easier record of RSS hits sometimes...
Proud Raider; General of The Black Hawks, Ret.
TG me anytime; I'm always happy to talk about anything!

The Alicorns (Equestria) wrote:Let them stay, no need to badmouth them...From our view a bunch of nations just came in, seized the delegate position, and changed a few superficial things...we play NationStates differently...there's really no reason for us to be butthurt.
http://www.nationstates.net/page=rmb/postid=8944227
http://www.nationstates.net/page=rmb/postid=8951258

Misley wrote:
Hobbesistan wrote:Don't think I understand the question.
The color or what?..

Jesus, Hobbes, it's 2015. You can't just call someone "the color".

Reploid Productions wrote:Raiders are endlessly creative

How Do I Telegram API?

Omnis delenda est.

User avatar
The Vines
Secretary
 
Posts: 36
Founded: Oct 25, 2014
Civil Rights Lovefest

Postby The Vines » Fri Jun 26, 2015 2:21 am

Letoilenoir wrote:
Letoilenoir wrote:Courtesy of The Red Fleet N.U.T.Cracker


Just a heads up to those of you who have found the Pipes tool above useful, Yahoo is dropping pipes from 25th September 2015 so this method of finding update times will no longer be available in this form

I may get around to coding a more permanent solution if there is a demand but in the meantime I hope that it has helped and thank those who have employed it since its inception

Out of curiosity, what did that tool do?
Ambassador of the Vines - Factbook - NS API for Haskell
I love you

User avatar
Letoilenoir
Chargé d'Affaires
 
Posts: 424
Founded: Nov 26, 2010
Ex-Nation

Postby Letoilenoir » Fri Jun 26, 2015 2:38 pm

Image

Retrieved legislation data on nations (aka last update times) and presented it in a user friendly format.
Using three nations could allow triangulation on a given regions update time for planning raids etc
KEEP THE BLOOD CAVE FREE

User avatar
King Nephmir II
Chargé d'Affaires
 
Posts: 400
Founded: Jun 04, 2015
Benevolent Dictatorship

Postby King Nephmir II » Fri Jun 26, 2015 4:49 pm

I believe the activity page does that now, actually, if you click on the timestamp it'll convert it to a readable time format.

Originally started out with the pipes. Too bad they must go!

User avatar
Minoa
Negotiator
 
Posts: 6072
Founded: Oct 05, 2011
Civil Rights Lovefest

Postby Minoa » Sat Jun 27, 2015 12:50 am

I may make an NSindex article on N.U.T. Cracker: I assume that "NUT" stood for NationStates Update Time?
Mme A. d'Oiseau, B.A. (State of Minoa)

User avatar
The Vines
Secretary
 
Posts: 36
Founded: Oct 25, 2014
Civil Rights Lovefest

Postby The Vines » Sat Jun 27, 2015 8:26 pm

Letoilenoir wrote:*snip*

Retrieved legislation data on nations (aka last update times) and presented it in a user friendly format.
Using three nations could allow triangulation on a given regions update time for planning raids etc

Makes sense, thanks!
Ambassador of the Vines - Factbook - NS API for Haskell
I love you

User avatar
Lordieth
Post Czar
 
Posts: 31603
Founded: Jun 18, 2010
New York Times Democracy

Postby Lordieth » Sun Jun 28, 2015 1:29 pm

Could someone share the technicals on this? Where exactly did it obtain the data? It might be possible just to write a script that does the same thing.
There was a signature here. It's gone now.

User avatar
Letoilenoir
Chargé d'Affaires
 
Posts: 424
Founded: Nov 26, 2010
Ex-Nation

Postby Letoilenoir » Mon Jun 29, 2015 12:37 pm

Lordieth wrote:Could someone share the technicals on this? Where exactly did it obtain the data? It might be possible just to write a script that does the same thing.


Image

Image

Okay process was as follows

4 user input fields = these would be the nations that were being used for the emquiry - in pipes there was a need to set a default nation purely for testing

This input would be used to create the url to retrieve the data:

Eg Input: Letoilenoir URL created :
http://www.nationstates.net/cgi-bin/api.cgi?nation=letoilenoir

This would return data along the lines of this:
The Chrononauts of Letoilenoir was ranked in the Top 10% of the world for Largest Basket Weaving Sector
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir was ranked in the Top 10% of the world for Largest Retail Industry
Following new legislation in The Chrononauts of Letoilenoir, foreign 'investors' have been taking a great interest in the new secret shuttle
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
+22 more...


It would be the "legislation" line highlighted above that we were interested in so a filter was applied to only let through items containing "legislation"

The "itemPubDate" was the crucial piece of info being the timestamp of the update - The RSS creator was configured to show this info along with a link to the nation and a description of the item

Finally the results were sorted in descending order so that the latest activity was displayed first.
Using this you could quickly compare the update times of up to four regions (eg tracer region, trigger region, target region) and fed into the output.

Going forward It would be logical to assume that using the "legislation" shard of a nation would remove the need for the filter, however this particular shard does not appear to contain a timestamp:
<NATION id="letoilenoir">
<LEGISLATION>
<LAW>
<![CDATA[
a niche industry catering to S&amp;M enthusiasts has sprung up
]]>
</LAW>
<LAW>
<![CDATA[
the nation has welcomed its expats back with open arms
]]>
</LAW>
<LAW>
<![CDATA[
tightly packed choir-boys sing the god-given joys of heterosexuality on public transport
]]>
</LAW>
<LAW>
<![CDATA[
foreign 'investors' have been taking a great interest in the new secret shuttle
]]>
</LAW>
</LEGISLATION>
</NATION>


The "happenings" shard however does:
<NATION id="letoilenoir">
<HAPPENINGS>
<EVENT>
<TIMESTAMP>1434951862</TIMESTAMP>
<TEXT>
@@letoilenoir@@ was ranked in the Top 10% of the world for Largest Basket Weaving Sector.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1434403528</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1434402683</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1430573574</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1430522764</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1427265039</TIMESTAMP>
<TEXT>
@@letoilenoir@@ was ranked in the Top 10% of the world for Largest Retail Industry.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1425189299</TIMESTAMP>
<TEXT>
Following new legislation in @@letoilenoir@@, foreign 'investors' have been taking a great interest in the new secret shuttle.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1425161794</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1425161769</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1424155680</TIMESTAMP>
<TEXT>
@@letoilenoir@@ was ranked in the Top 10% of the world for Most Godforsaken (last census: Top 5%).
</TEXT>
</EVENT>
</HAPPENINGS>
</NATION>


So it would seem that the filter will still be necessary

Effectively then we are looking at four calls to the api to retrieve the "happenings" shard, apply a filter to extract the legislation data, and echo the timestamp (yes I'm thinking php) formatted in a human readable form, and sorting them by most recent to mimic the functionality of the original

My thinking is a form to capture the user input (the four nations) populating an array. Then a foreach loop to call the data from the api -

Echoing and formatting the timestamp should be reasonably straighforward(once I get the fist stage working properly, but the sorting is beyond my scope......at the moment

Input, suggestions and help gladly welcomed
KEEP THE BLOOD CAVE FREE

User avatar
Misley
Diplomat
 
Posts: 609
Founded: Jan 05, 2009
Ex-Nation

Postby Misley » Mon Jun 29, 2015 1:25 pm

I think the explanation that you've given for a PHP replacement for NUTCracker makes sense, but what's the value of finding previous update times through this, other than having a general idea of when the region updates? NUTCracker, while useful, wasn't adequate for update operations that require a higher level of precision - especially for regions that don't have nations answering issues.
EGO·VERO·CUSTOSFRATRIS·MEI·SUM
Socialist People's Provinces of Misley

   
Editor of the Red & Black
Fleet Admiral of The Red Fleet
Custodian of The Internationale

User avatar
Letoilenoir
Chargé d'Affaires
 
Posts: 424
Founded: Nov 26, 2010
Ex-Nation

Postby Letoilenoir » Mon Jun 29, 2015 2:26 pm

Misley wrote:I think the explanation that you've given for a PHP replacement for NUTCracker makes sense, but what's the value of finding previous update times through this, other than having a general idea of when the region updates? NUTCracker, while useful, wasn't adequate for update operations that require a higher level of precision



On its own N.U.T Cracker never pretended to provide definitive update times for a given region. However, used in conjunction with the update schedule it allowed a fairly painless way to position your triggers, choose your jump-points and narrow down the window of opportunity.

Misley wrote:Iespecially for regions that don't have nations answering issues.

Even if your target region has no updating nations those either side of it may, allowing you to use these as proxies and set you triggers accordingly.

It should be considered an entry level tool for those wanting to become involved in R/D without wanting to set up an extensive network of series triggers - it never claimed to put the ball in the back of the net but at least it got you onto the pitch!
KEEP THE BLOOD CAVE FREE

User avatar
Lordieth
Post Czar
 
Posts: 31603
Founded: Jun 18, 2010
New York Times Democracy

Postby Lordieth » Wed Jul 01, 2015 12:10 pm

Letoilenoir wrote:
Lordieth wrote:Could someone share the technicals on this? Where exactly did it obtain the data? It might be possible just to write a script that does the same thing.


Image

Image

Okay process was as follows

4 user input fields = these would be the nations that were being used for the emquiry - in pipes there was a need to set a default nation purely for testing

This input would be used to create the url to retrieve the data:

Eg Input: Letoilenoir URL created :
http://www.nationstates.net/cgi-bin/api.cgi?nation=letoilenoir

This would return data along the lines of this:
The Chrononauts of Letoilenoir was ranked in the Top 10% of the world for Largest Basket Weaving Sector
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
The Chrononauts of Letoilenoir was ranked in the Top 10% of the world for Largest Retail Industry
Following new legislation in The Chrononauts of Letoilenoir, foreign 'investors' have been taking a great interest in the new secret shuttle
The Chrononauts of Letoilenoir lodged a message on the The Blood Cave Regional Message Board
+22 more...


It would be the "legislation" line highlighted above that we were interested in so a filter was applied to only let through items containing "legislation"

The "itemPubDate" was the crucial piece of info being the timestamp of the update - The RSS creator was configured to show this info along with a link to the nation and a description of the item

Finally the results were sorted in descending order so that the latest activity was displayed first.
Using this you could quickly compare the update times of up to four regions (eg tracer region, trigger region, target region) and fed into the output.

Going forward It would be logical to assume that using the "legislation" shard of a nation would remove the need for the filter, however this particular shard does not appear to contain a timestamp:
<NATION id="letoilenoir">
<LEGISLATION>
<LAW>
<![CDATA[
a niche industry catering to S&amp;M enthusiasts has sprung up
]]>
</LAW>
<LAW>
<![CDATA[
the nation has welcomed its expats back with open arms
]]>
</LAW>
<LAW>
<![CDATA[
tightly packed choir-boys sing the god-given joys of heterosexuality on public transport
]]>
</LAW>
<LAW>
<![CDATA[
foreign 'investors' have been taking a great interest in the new secret shuttle
]]>
</LAW>
</LEGISLATION>
</NATION>


The "happenings" shard however does:
<NATION id="letoilenoir">
<HAPPENINGS>
<EVENT>
<TIMESTAMP>1434951862</TIMESTAMP>
<TEXT>
@@letoilenoir@@ was ranked in the Top 10% of the world for Largest Basket Weaving Sector.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1434403528</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1434402683</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1430573574</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1430522764</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1427265039</TIMESTAMP>
<TEXT>
@@letoilenoir@@ was ranked in the Top 10% of the world for Largest Retail Industry.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1425189299</TIMESTAMP>
<TEXT>
Following new legislation in @@letoilenoir@@, foreign 'investors' have been taking a great interest in the new secret shuttle.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1425161794</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1425161769</TIMESTAMP>
<TEXT>
@@letoilenoir@@ lodged a message on the %%the_blood_cave%% Regional Message Board.
</TEXT>
</EVENT>
<EVENT>
<TIMESTAMP>1424155680</TIMESTAMP>
<TEXT>
@@letoilenoir@@ was ranked in the Top 10% of the world for Most Godforsaken (last census: Top 5%).
</TEXT>
</EVENT>
</HAPPENINGS>
</NATION>


So it would seem that the filter will still be necessary

Effectively then we are looking at four calls to the api to retrieve the "happenings" shard, apply a filter to extract the legislation data, and echo the timestamp (yes I'm thinking php) formatted in a human readable form, and sorting them by most recent to mimic the functionality of the original

My thinking is a form to capture the user input (the four nations) populating an array. Then a foreach loop to call the data from the api -

Echoing and formatting the timestamp should be reasonably straighforward(once I get the fist stage working properly, but the sorting is beyond my scope......at the moment

Input, suggestions and help gladly welcomed


Let me see what I can do.
There was a signature here. It's gone now.

User avatar
Lordieth
Post Czar
 
Posts: 31603
Founded: Jun 18, 2010
New York Times Democracy

Postby Lordieth » Wed Jul 01, 2015 1:15 pm

This will require testing, but I've done the bare minimum to ensure it works.

Be sure to set the user agent on line 8, and the correct timezone on line 10, so you get the correct update times

Code: Select all
<?php
//======================================================================
// Update Time Tool 1.0 - Written by Lordieth
//======================================================================
//
//I take no responsibility for the use (or misuse) of this script. Use at your own risk.

ini_set("user_agent","Nation update time checker, ran by [nation] - see https://forum.nationstates.net/viewtopic.php?f=15&t=345458");
//set your timezone here to get the correct returned update times
date_default_timezone_set("Europe/London");
//here we'll store any errors
$errors = array();

//this is where we'll store the results, if any
$results = array();
if(isset($_POST['submit'])){
    //print_r($_POST['nation']);
    if(empty($_POST['nation'][0])){
        $errors[] = "Nation 1 has not been entered";
    }
    if(empty($_POST['nation'][1])){
        $errors[] = "Nation 2 has not been entered";
    }
    if(empty($_POST['nation'][2])){
        $errors[] = "Nation 3 has not been entered";
    }
    if(empty($_POST['nation'][3])){
        $errors[] = "Nation 4 has not been entered";
    }
    if(empty($errors)){
       
        //no errors, now we can run.
        $i = 0;
        $events = array();
        foreach($_POST['nation'] as $nation){
           
            //replace spaces with underscores to make nation name url-friendly
            $nation = str_replace(" ", "_", trim($nation));
           
            $page = @file_get_contents("http://www.nationstates.net/cgi-bin/api.cgi?nation=".trim($nation)."&q=happenings");
            sleep(5);
           
            $xml = simplexml_load_string($page);
            $json = json_encode($xml);
            $array = json_decode($json,TRUE);
           
            //echo "<pre>";
            //print_r($array);
            //echo "</pre>";
            //die();
            if($array){
               $events = $array['HAPPENINGS']['EVENT'];
            }
            else{
                $errors[] = $nation. " could not be found.<br>";
            }
           
            if($events){
                foreach($events as $event){
               
                //echo $event['TEXT']."<br>";
                    if(strpos($event['TEXT'], "Following new legislation") !== false){
                        $results[$i]['TEXT'] = $event['TEXT'];
                        $results[$i]['TIMESTAMP'] = $event['TIMESTAMP'];

                        $i++;
                        break;
                    }
                }
               
            }
           
           
        }
    }
       
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        if($errors){
            foreach($errors as $error){
            echo $error."<br>";
            }
            echo "<br>";
        }
       
        ?>
         <form action="index.php" method="post">
        Nation 1: <input type="text" name="nation[]"><br>
        Nation 2: <input type="text" name="nation[]"><br>
        Nation 3: <input type="text" name="nation[]"><br>
        Nation 4: <input type="text" name="nation[]"><br>
        <input type="submit" name ="submit" value="Submit">
        </form>
        <?php
        if($results){
            //echo "<pre>";
            //print_r($results);
            //echo "</pre>";
            usort($results, 'date_compare');
            //echo "<pre>";
            //print_r($results);
            //echo "</pre>";
            //die();
            foreach($results as $result){
                echo date("D M j G:i:s", $result['TIMESTAMP'])."<br>";
                echo $result['TEXT']."<br>";

            }
            echo "<br><br>";
        }
        ?>
    </body>
</html>
<?php
function date_compare($a, $b)
{
    return $a['TIMESTAMP'] < $b['TIMESTAMP'];
}   


?>


Let me know of any bugs, or if it's returning the incorrect times. They should be sorted correctly, but any problems, let me know. Once it's all been fully tested, I'll polish it off, and I'll give it its own thread. In the meantime; enjoy.

Edit: There's a bug with the dates, I think. I'll sort it out tomorrow.
Last edited by Lordieth on Thu Jul 02, 2015 10:25 am, edited 3 times in total.
There was a signature here. It's gone now.

User avatar
Letoilenoir
Chargé d'Affaires
 
Posts: 424
Founded: Nov 26, 2010
Ex-Nation

Postby Letoilenoir » Wed Jul 01, 2015 4:49 pm

Cheers Lordieth! Working example

Seems to be working:
Image

Image

Image

Image

Questions:
It could be the cross server call is slowing things down but the process is slow at the moment.
Is the "sleep" really necessary if we are only making 4 calls to the API?

Code: Select all
$page = @file_get_contents("http://www.nationstates.net/cgi-bin/api.cgi?nation=".trim($nation)."&q=happenings");
           sleep(5);


Would removing this speed things up?
Last edited by Letoilenoir on Wed Jul 01, 2015 4:58 pm, edited 2 times in total.
KEEP THE BLOOD CAVE FREE

User avatar
Lordieth
Post Czar
 
Posts: 31603
Founded: Jun 18, 2010
New York Times Democracy

Postby Lordieth » Wed Jul 01, 2015 11:26 pm

Aye. I put it there just to ensure I didn't exceed the API rate limit during testing. A better way would be using a session to keep track of API calls to make sure the rate isn't exceeded. I'll look into it.

You can put // in front of sleep and that'll speed it up, just be mindful not to exceed the API rate limit. Not likely to happen, but still.
Last edited by Lordieth on Wed Jul 01, 2015 11:29 pm, edited 2 times in total.
There was a signature here. It's gone now.

User avatar
Letoilenoir
Chargé d'Affaires
 
Posts: 424
Founded: Nov 26, 2010
Ex-Nation

Postby Letoilenoir » Thu Jul 02, 2015 2:26 pm

Series of error messages prompted by (deliberately) mis-spelled nation names
PHP Error Message

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 3: parser error : Extra content at the end of the document in /home/a9159330/public_html/lordeith3.php on line 43

Free Web Hosting

PHP Error Message

Warning: simplexml_load_string() [function.simplexml-load-string]: <p style="font-size:small">Error: 404 Not Found in /home/a9159330/public_html/lordeith3.php on line 43

PHP Error Message

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/a9159330/public_html/lordeith3.php on line 43

Free Web Hosting

PHP Error Message

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 3: parser error : Extra content at the end of the document in /home/a9159330/public_html/lordeith3.php on line 43


PHP Error Message

Warning: simplexml_load_string() [function.simplexml-load-string]: <p style="font-size:small">Error: 404 Not Found in /home/a9159330/public_html/lordeith3.php on line 43

PHP Error Message

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/a9159330/public_html/lordeith3.php on line 43

trinovantum could not be found.

loredeith could not be found.


NB executed using the updated code

Otherwise using properly named nations:

Thu Jul 2 17:56:53
Following new legislation in @@linhartia@@, bicyclists are banned from major roads.
Thu Jul 2 17:21:16
Following new legislation in @@jayzonia@@, a well-funded social safety net protects the unfortunate.
Thu Jul 2 17:17:42
Following new legislation in @@hurtion@@, young children are regularly seen wagering pocket money at blackjack tables.
Thu Jul 2 17:13:38
Following new legislation in @@palombria@@, organ donation rates are among the lowest in the region.


Just a thought: if the "region" shard is also requested and echoed for each nation then there would be a visual update time for the region!
Last edited by Letoilenoir on Thu Jul 02, 2015 2:42 pm, edited 1 time in total.
KEEP THE BLOOD CAVE FREE

User avatar
Lordieth
Post Czar
 
Posts: 31603
Founded: Jun 18, 2010
New York Times Democracy

Postby Lordieth » Thu Jul 02, 2015 2:53 pm

Ah. I'll put in some extra checks to validate nations, or i'll just suppress those error messages as they don't affect the output that I can see. If the API throws a 404 I can probably check for it.

As for outputting the region name for each nation using the region shard; no problem. I'll make both these changes tomorrow.

If there's any call for pulling in more shards, I'll add the ability to define which shards you want to include and output with each nation.
Last edited by Lordieth on Thu Jul 02, 2015 2:58 pm, edited 2 times in total.
There was a signature here. It's gone now.

User avatar
Letoilenoir
Chargé d'Affaires
 
Posts: 424
Founded: Nov 26, 2010
Ex-Nation

Postby Letoilenoir » Thu Jul 02, 2015 3:35 pm

Lordieth wrote:Ah. I'll put in some extra checks to validate nations, or i'll just suppress those error messages as they don't affect the output that I can see. If the API throws a 404 I can probably check for it.

As for outputting the region name for each nation using the region shard; no problem. I'll make both these changes tomorrow.

If there's any call for pulling in more shards, I'll add the ability to define which shards you want to include and output with each nation.


Cool! :bow:

Could I ask a big favour?

Could you comment as much as possible (even stuff that is remedial/101 coding) so that I can try to get to grips with what each section is doing?
For instance, I would like to format the "@@nation@@" (and more probably the @@region@@) output as a hyperlink, but need to identify which element to adjust.
KEEP THE BLOOD CAVE FREE

User avatar
Lordieth
Post Czar
 
Posts: 31603
Founded: Jun 18, 2010
New York Times Democracy

Postby Lordieth » Fri Jul 03, 2015 10:47 am

Letoilenoir wrote:
Lordieth wrote:Ah. I'll put in some extra checks to validate nations, or i'll just suppress those error messages as they don't affect the output that I can see. If the API throws a 404 I can probably check for it.

As for outputting the region name for each nation using the region shard; no problem. I'll make both these changes tomorrow.

If there's any call for pulling in more shards, I'll add the ability to define which shards you want to include and output with each nation.


Cool! :bow:

Could I ask a big favour?

Could you comment as much as possible (even stuff that is remedial/101 coding) so that I can try to get to grips with what each section is doing?
For instance, I would like to format the "@@nation@@" (and more probably the @@region@@) output as a hyperlink, but need to identify which element to adjust.


Absolutely! Once I've done a bit more work on it, I'll start fleshing it out with comments. Funny you should mention the @@value@@ outputs, as I was actually thinking of turning them into links. Regular expressions are the way to go, with those. I'll be happy to implement it. I probably won't get an update out tonight, but by this weekend, I'll post a script update.
There was a signature here. It's gone now.

User avatar
Letoilenoir
Chargé d'Affaires
 
Posts: 424
Founded: Nov 26, 2010
Ex-Nation

Postby Letoilenoir » Fri Jul 03, 2015 11:14 am

Could the timezone be a user input via a dropdown box:

Code: Select all
<?php
 
function get_timezones()
{
    $o = array();
     
    $t_zones = timezone_identifiers_list();
     
    foreach($t_zones as $a)
    {
        $t = '';
         
        try
        {
            //this throws exception for 'US/Pacific-New'
            $zone = new DateTimeZone($a);
             
            $seconds = $zone->getOffset( new DateTime("now" , $zone) );
            $hours = sprintf( "%+02d" , intval($seconds/3600));
            $minutes = sprintf( "%02d" , ($seconds%3600)/60 );
     
            $t = $a ."  [ $hours:$minutes ]" ;
             
            $o[$a] = $t;
        }
         
        //exceptions must be catched, else a blank page
        catch(Exception $e)
        {
            //die("Exception : " . $e->getMessage() . '<br />');
            //what to do in catch ? , nothing just relax
        }
    }
     
    ksort($o);
     
    return $o;
}
 
$o = get_timezones();
?>
 
<html>
<body>
<select name="time_zone">
<?php
    foreach($o as $tz => $label)
    {
        echo "<option value="$tz">$label</option>";
    }
?>
</select>
</body>
</html>


source: http://www.binarytides.com/dropdown-list-timezones-php/
KEEP THE BLOOD CAVE FREE

User avatar
Lordieth
Post Czar
 
Posts: 31603
Founded: Jun 18, 2010
New York Times Democracy

Postby Lordieth » Fri Jul 03, 2015 1:02 pm

I've moved this to it's own thread here, where I've posted the latest update. I won't be posting updates here now, as I think it's deserving of its own thread now.
Last edited by Lordieth on Fri Jul 03, 2015 1:02 pm, edited 1 time in total.
There was a signature here. It's gone now.


Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Axilea, BLACKGRUE, Magnoliids, New Verodania, Outer Sparta, Riemstagrad, Second Peenadian, The Southern Dependencies

Advertisement

Remove ads