Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1303 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  URL syntaxe

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

URL syntaxe

n°1925081
nicx
Posté le 18-09-2009 à 14:56:54  profilanswer
 

bonjours,
 
je suis pas bon en codage, je dois faire un lien présent sur une page htm et une fonction php d'une page.
 
en faite, c'est un soft constitué de 3 page php, une pour lui mettre les valeurs des différents switch (ip, nom ..) voir plus bas, une deuxieme ou y a la config, et une troisieme, qui sert juste a lui dire qu'il y a 2 autre page et mettre du code html.
 
je vous montre :
 
 
partie page htm

Code :
  1. <AREA shape="POLYGON" tabindex="1" ALT="c0000-000" origTitle="c0000-000" TITLE="c0000-000" HREF="telnet://192.192.192.192/" target="_top"


Je vais remplacer l'appel telnet par un lien http vers une page php.
 
Si je lui met un lien vers la page php, j'aurais accès à toute la config que ce script me donne.
Je ne veux pas accéder à tous d'un seule coup mais plutôt juste au matériel que je viens d'appeler.
 
page php:

Code :
  1. // Specify the look you wish lists to have here: ('radio'/'select')
  2. $switch_list_style = 'select';
  3. $request_list_style = 'radio';
  4. $socket_timeout = 5;
  5. // default values for all switch, used if there is no more specific setting
  6. $switch['default']['telnet_port'] = xx;
  7. $switch['default']['password'] = 'tralala';
  8. $switch['default']['password_en'] = "tralala";
  9. $switch['default']['ignore_argc'] = FALSE;
  10. // your switch
  11. // I recommend using of key numbers with step of 10, it allows to insert new
  12. // declarations without reordering the rest of list. As in BASIC or DNS MX.
  13.   /*
  14.   $switch[850]['title'] = 'c0000-000';
  15. $switch[850]['address'] = '192.192.192.192';
  16. $switch[850]['services'] = 'telnet';
  17. $switch[850]['username'] = 'mr';
  18. //$switch[850]['password'] = 'tralala';
  19. $switch[860]........
  20. $switch[870]....


 
 
le truc c'est que je voudrai par le biais de l'url, je puisse directement lancer $switch[850]
 
 
 
la page de config php:

Code :
  1. function printError ($message)
  2. {
  3. echo "<font color=red><code><strong>" . $message . "</strong></code></font><br>\n";
  4. }
  5. function safeOutput ($string)
  6. {
  7. return htmlentities (substr ($string, 0, 50));
  8. }
  9. function printSwitchList ($switch, $type)
  10. {
  11. if ($type == "select" ) echo "<select name=switchid>\n";
  12. while (list ($id, $attribute) = each ($switch))
  13.  if (strcmp ($id, "default" ) && !empty($attribute["address"]))
  14.  {
  15.   if ($type == "select" ) echo "<option value={$id}";
  16.   if ($type == "radio" ) echo "<input type=radio name=switchid value={$id}";
  17.   if ($_REQUEST["switchid"] == $id)
  18.   {
  19.    if ($type == "select" ) echo " selected=on";
  20.    if ($type == "radio" ) echo " checked=on";
  21.   }
  22.   echo ">";
  23.   echo $attribute["title"] ? $attribute["title"] : $attribute["address"];
  24.   if ($type == "select" ) echo "</option>\n";
  25.   if ($type == "radio" ) echo "</input><br>\n";
  26.  }
  27. if ($type == "select" ) echo "</{$type}>\n";
  28. }
  29. function printRequestList ($request, $type)
  30. {
  31. if ($type == "select" ) echo "<select name=requestid>";
  32. while (list($id, $attribute) = each ($request))
  33.  if (!empty ($attribute["command"]) && !empty ($attribute["handler"]) && isset ($attribute["argc"]))
  34.  {
  35.   if ($type == "select" ) echo "<option value={$id}";
  36.   if ($type == "radio" ) echo "<input type=radio name=requestid value={$id}";
  37.   if ($_REQUEST["requestid"] == $id)
  38.   {
  39.    if ($type == "select" ) echo " selected=on";
  40.    if ($type == "radio" ) echo " checked=on";
  41.   }
  42.   echo ">";
  43.   echo $attribute["title"] ? $attribute["title"] : $attribute["command"];
  44.   if ($type == "select" ) echo "</option>\n";
  45.   if ($type == "radio" ) echo "</input><br>\n";
  46.  }
  47. echo "</{$type}>\n";
  48. }
  49. function execPreviousRequest ($switch, $request)
  50. {
  51. if (!isset($_REQUEST["switchid"])) return;
  52. $switchid = $_REQUEST["switchid"];
  53. if (!isset ($switch[$switchid]["address"])) return;
  54. if (!isset($_REQUEST["requestid"])) return;
  55. $requestid = $_REQUEST["requestid"];
  56. if (!isset ($request[$requestid]["argc"])) return;
  57. $handler = $request[$requestid]["handler"];
  58. if (empty ($handler) || strpos ($switch[$switchid]["services"], $handler) === false)
  59. {
  60.  printError ("This request is not permitted for this switch by administrator." );
  61.  return;
  62. }
  63. if ($request[$requestid]["argc"] > 0)
  64. {
  65.  if (trim ($_REQUEST["argument"]) == '')
  66.  {
  67.   $switch_defined = isset ($switch[$switchid]["ignore_argc"]);
  68.   $switch_permits = $switch[$switchid]["ignore_argc"] == 1;
  69.   $default_defined = isset ($switch["default"]["ignore_argc"]);
  70.   $default_permits = $switch["default"]["ignore_argc"] == 1;
  71.   $final_permits =
  72.    (!$switch_defined && $default_defined && $default_permits) ||
  73.    ($switch_defined && $switch_permits);
  74.   if (!$final_permits)
  75.   {
  76.    printError ("Full table view is denied on this switch" );
  77.    return;
  78.   }
  79.  }
  80.  else $argument = trim ($_REQUEST["argument"]);
  81. }
  82. // All Ok, prepare to connect.
  83. $address = $switch[$switchid]["address"];
  84. if (!empty ($switch[$switchid][$handler . "_port"]))
  85.  $port = $switch[$switchid][$handler . "_port"];
  86. else
  87.  $port = $switch["default"][$handler . "_port"];
  88. if (!empty ($switch[$switchid][$handler . "_password"]))
  89.  $password = $switch[$switchid][$handler . "_password"];
  90. elseif (!empty ($switch[$switchid]["password"]))
  91.  $password = $switch[$switchid]["password"];
  92. else
  93.  $password = $switch["default"]["password"];
  94. $command = $request[$requestid]["command"] . (!empty ($argument) ? (" " . safeOutput ($argument)) : "" );
  95. global $socket_timeout;
  96. $link = fsockopen ($address, $port, $errno, $errstr, $socket_timeout);
  97. if (!$link)
  98. {
  99.  printError ("Error connecting to switch" );
  100.  return;
  101. }
  102. socket_set_timeout ($link, $socket_timeout);
  103. $username = $switch[$switchid]["username"];
  104. if (!empty ($username)) fputs ($link, "{$username}\n" );
  105. fputs ($link, "{$password}\nterminal length 0\n{$command}\n" );
  106. // let daemon print bulk of records uninterrupted
  107. if (empty ($argument) && $request[$requestid]["argc"] > 0) sleep (2);
  108. fputs ($link, "quit\n" );
  109. echo "<pre>\n";
  110. // Skip text up to the line following out command.
  111. while (!feof ($link)
  112.  && (strpos (fgets ($link, 1024), $command) === FALSE));
  113. // Skip everything up to the 'quit' command.
  114. while (!feof ($link)
  115.  && (strpos (($buf = fgets ($link, 1024)), "quit" ) === FALSE))
  116. {
  117.  echo $buf;
  118. }
  119. echo "</pre>\n";
  120. fclose ($link);
  121. }
  122. ?>


Message édité par nicx le 18-09-2009 à 15:45:49
mood
Publicité
Posté le 18-09-2009 à 14:56:54  profilanswer
 

n°1925091
pataluc
Posté le 18-09-2009 à 15:32:50  profilanswer
 

http://www.fouin.org/pommedefennec/images/smiles/GS/GS_5d92216555317bd9bc79943018263139.png
 
c'est illisible la ca donne pas envie de lire ton post, tes questions sont mélangées à ton code.

n°1925093
nicx
Posté le 18-09-2009 à 15:46:15  profilanswer
 

c'est mieux non ?
désolé, j'avais pas vu les balises pour le code   :sweat:


Message édité par nicx le 18-09-2009 à 15:47:36
n°1925117
rufo
Pas me confondre avec Lycos!
Posté le 18-09-2009 à 17:00:01  profilanswer
 

faut passer l'id du switch dans l'url  du genre :
http://MonServeur/MonScript.php?idswitch=850
 
et dans MonScript.php tu vas récupérer l'id du switch via la variable $_GET['idswitch'] (avec les méthodes de protection qui vont bien pour pas te faire hacker)...


Message édité par rufo le 18-09-2009 à 17:00:10

---------------
Astres, outil de help-desk GPL : http://sourceforge.net/projects/astres, ICARE, gestion de conf : http://sourceforge.net/projects/icare, Outil Planeta Calandreta : https://framalibre.org/content/planeta-calandreta
n°1925462
nicx
Posté le 21-09-2009 à 09:36:40  profilanswer
 

merci, ca marche nickel avec ça :)


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  URL syntaxe

 

Sujets relatifs
La syntaxe de FOAF[Résolu] [vba] aide à la syntaxe pour la dimension d'un tableau
URL REWRITTINGsvn: 'C:\machin is already a working copy for a different URL
Mettre autre URL en phpCheck URL avec pycurl
Obtenir l'URL en cours rewriting inclus mais variables GET exclusProblème avec fonction header() + syntaxe.
Syntaxe Lien relatif ExcelSyntaxe d'une URL pointant sur un fichier local
Plus de sujets relatifs à : URL syntaxe


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR