@@ -803,36 +803,27 @@ function parse_SNGM(&$textall)
803
803
function parse_Skirando (&$ textall ,$ last_id )
804
804
{
805
805
global $ dlim ;
806
- // on garde que la partie interessante.
807
- $ entries = explode ('</tr> ' ,substr ($ textall ,strpos ($ textall ,'<tbody> ' )));
808
- $ textall = '' ;
809
- $ new_id = $ last_id ;
810
806
811
- $ n = count ($ entries )-1 ;
812
- for ($ i = 0 ;$ i <$ n ; $ i ++)
813
- {
814
- $ items = explode ('</td> ' ,$ entries [$ i ]);
815
- $ lien = substr ($ items [1 ],strpos ($ items [1 ],'<a href=".. ' )+9 );
816
- $ lien = substr ($ lien ,0 ,strpos ($ lien ,'"> ' ));
817
- ereg ('/outings/([0-9]+) ' ,$ lien ,$ regs ); $ id = $ regs [1 ];
818
- if ($ id > $ last_id )
819
- {
820
- $ nom = trim (strip_tags ($ items [1 ]));
821
- $ date = trim (strip_tags ($ items [2 ]));
822
- $ cot = trim (strip_tags ($ items [6 ]));
823
- $ reg = trim (strip_tags ($ items [9 ]));
824
- $ part = trim (strip_tags ($ items [12 ]));
825
- // interprete la date :
826
- $ jma = explode (' ' ,$ date );
827
- if (strlen ($ jma [0 ]) == 1 ) $ jma [0 ] = "0 {$ jma [0 ]}" ;
828
- $ date = "{$ jma [2 ]}- " . get_mois ($ jma [1 ]) . "- {$ jma [0 ]}" ;
829
- // pour etre ecrit plus tard :
830
- if ($ date < $ dlim ) break ; // pas plus vieux que 1 mois.
831
- $ textall .= "c2c $ id \n$ date $ cot \n$ nom \nhttp://www.camptocamp.org/outings/ $ id \n$ reg \n$ part \n" ;
832
- if ($ id > $ new_id ) $ new_id = $ id ;
833
- }
834
- }
835
- return $ new_id ;
807
+ $ obj = json_decode ($ textall , true );
808
+ $ outings = $ obj ['documents ' ];
809
+ $ textall = '' ;
810
+
811
+ $ new_id = $ last_id ;
812
+
813
+ foreach ($ outings as $ outing ) {
814
+ $ id = $ outing ['document_id ' ];
815
+ $ date = $ outing ['date_start ' ];
816
+ $ name = $ outing ['locales ' ][0 ]['title ' ];
817
+ $ link = 'https://www.camptocamp.org/outings/ ' . $ id ;
818
+ $ area = get_area ($ outing );
819
+ $ cotation = "" ; // TODO get_cotation($outing);
820
+ $ author = $ outing ['author ' ]['name ' ];
821
+ if ($ date < $ dlim ) break ; // not older than one month
822
+ $ textall .= "c2c $ id \n$ date $ cotation \n$ name \n$ link \n$ area \n$ author \n" ;
823
+ if ($ id > $ new_id ) $ new_id = $ id ;
824
+ }
825
+
826
+ return $ new_id ;
836
827
}
837
828
838
829
// cherche la cot d'une volo-course si dispo (et ajoute les participants !)
0 commit comments