default
[ class tree: default ] [ index: default ] [ all elements ]

Source for file examples.guifi_api.link.php

Documentation is available at examples.guifi_api.link.php

  1. <?php
  2. // The source code packaged with this file is Free Software, Copyright (C) 2005 by
  3. // Eduard Duran <eduard.duran at iglu.cat>.
  4. // It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
  5. // You can get copies of the licenses here:
  6. //         http://www.affero.org/oagpl.html
  7. // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "LICENSE.txt".
  8.  
  9. require 'guifi_api.php' );
  10.  
  11. /**
  12.  * Configuration of authentication against guifi.net
  13.  */
  14. $username "";
  15. $password "";
  16.  
  17. /**
  18.  * Code from here!
  19.  */
  20. $gapi new guifiAPI$username$password );
  21.  
  22. $action $_GET['action'];
  23.  
  24. switch$action {
  25.     case 'add':
  26.         $from_device_id 19534;
  27.         $from_radiodev_counter 2;
  28.         $to_device_id 8595;
  29.         $to_radiodev_counter 0;
  30.         
  31.         $link array();
  32.         $link['status''Building';
  33.         $link['ipv4''10.145.5.15';
  34.         
  35.         $added $gapi->addLink$from_device_id$from_radiodev_counter$to_device_id$to_radiodev_counter$link );
  36.         if$added {
  37.             echo "Link created correctly!!<br />\n<br />\n";
  38.             echo "The identificator of the new link is: link_id = <strong>$added->link_id</strong>";
  39.             if$added->ipv4 {
  40.                 $ipv4 $added->ipv4;
  41.                 echo "<br />\n<br />\n";
  42.                 echo "New IPv4 settings!:<br />";
  43.                 echo '<ul>';
  44.                 echo '<li>';
  45.                 echo "ipv4_type = $ipv4->ipv4_type<br />";
  46.                 echo "ipv4 = $ipv4->ipv4 <br />";
  47.                 echo "netmask = $ipv4->netmask<br />";
  48.                 echo '</li>';
  49.                 echo '</li>';
  50.             }
  51.             echo '</ul>';
  52.         else {
  53.             echo "There was an error adding the link.<br />\n";
  54.             echo $gapi->getErrorsStr();
  55.         }
  56.         break;
  57.     case 'update':
  58.         $link_id 21951;
  59.         
  60.         $link array();
  61.         $link['status''Working';
  62.         $link['ipv4''10.145.5.14';
  63.         
  64.         $updated $gapi->updateLink$link_id$link );
  65.         if$updated {
  66.             echo "Link <strong>$link_id</strong> was updated correctly.<br />\n<br />\n";
  67.         else {
  68.             echo "There was an error updating the link.<br />\n";
  69.             echo $gapi->getErrorsStr();
  70.         }
  71.         break;
  72.     case 'delete':
  73.         $link_id 21951;
  74.         
  75.         $removed $gapi->removeLink$link_id );
  76.         if$removed {
  77.             echo "Link <strong>$link_id</strong> removed correctly.<br />\n<br />\n";
  78.         else {
  79.             echo "There was an error deleting the link.<br />\n";
  80.             echo $gapi->getErrorsStr();
  81.         }
  82.         break;
  83. }
  84.  
  85. ?>

Documentation generated on Sun, 10 Jan 2010 21:02:49 +0100 by phpDocumentor 1.4.3