/[marcuscom]/switch-ztp/trunk/www/logicsw.php
ViewVC logotype

Diff of /switch-ztp/trunk/www/logicsw.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20638 by jclarke, Wed Jul 11 13:09:41 2018 UTC revision 20639 by jclarke, Thu Jul 25 13:51:36 2019 UTC
# Line 55  if (isset($_SERVER['REMOTE_USER'])) { Line 55  if (isset($_SERVER['REMOTE_USER'])) {
55      $ruser = $_SERVER['REMOTE_USER'];      $ruser = $_SERVER['REMOTE_USER'];
56  }  }
57    
 $errors = array();  
58  if (isset($_REQUEST['submit_top']) || isset($_REQUEST['submit_bottom'])) {  if (isset($_REQUEST['submit_top']) || isset($_REQUEST['submit_bottom'])) {
59      $pia = $_REQUEST['prev_ip_address'];      $pia = $_REQUEST['prev_ip_address'];
60      $ppid = $_REQUEST['prev_pid'];      $ppid = $_REQUEST['prev_pid'];
# Line 68  if (isset($_REQUEST['submit_top']) || is Line 67  if (isset($_REQUEST['submit_top']) || is
67      $exp = $_REQUEST['exception'];      $exp = $_REQUEST['exception'];
68      $idf = (isset($_REQUEST['is_idf'])) ? $_REQUEST['is_idf'] : array();      $idf = (isset($_REQUEST['is_idf'])) ? $_REQUEST['is_idf'] : array();
69      $d = (isset($_REQUEST['delete'])) ? $_REQUEST['delete'] : array();      $d = (isset($_REQUEST['delete'])) ? $_REQUEST['delete'] : array();
70        $made_change = false;
71      foreach ($pia as $sname => $value) {      foreach ($pia as $sname => $value) {
72          $curr_del = (isset($d[$sname])) ? $d[$sname] : 0;          $curr_del = (isset($d[$sname])) ? $d[$sname] : 0;
73            $errors = array();
74          if ($curr_del == 1) {          if ($curr_del == 1) {
75              if ($ia[$sname] !== null && $ia[$sname] != '') {              if ($ia[$sname] !== null && $ia[$sname] != '') {
76                  $sql = 'UPDATE ADDRESSES SET used=? WHERE address=?';                  $sql = 'UPDATE ADDRESSES SET used=? WHERE address=?';
# Line 95  if (isset($_REQUEST['submit_top']) || is Line 96  if (isset($_REQUEST['submit_top']) || is
96                  array_push($errors, "Failed to delete {$sname}: {$e->getMessage()}");                  array_push($errors, "Failed to delete {$sname}: {$e->getMessage()}");
97              }              }
98              if (count($errors) == 0) {              if (count($errors) == 0) {
99                    $made_change = true;
100                  @unlink(PORT_TMPL_DIR.'/devices/'."{$sname}-ports.tmpl");                  @unlink(PORT_TMPL_DIR.'/devices/'."{$sname}-ports.tmpl");
101              }              }
102              continue;              continue;
# Line 158  if (isset($_REQUEST['submit_top']) || is Line 160  if (isset($_REQUEST['submit_top']) || is
160              }              }
161          }          }
162          if (count($errors) == 0) {          if (count($errors) == 0) {
163                $made_change = true;
164              if ($pexp[$sname] != $exp[$sname]) {              if ($pexp[$sname] != $exp[$sname]) {
165                  if ($exp[$sname] != '__BOGUS__') {                  if ($exp[$sname] != '__BOGUS__') {
166                      @symlink(PORT_PROFILE_DIR.'/'.$exp[$sname], PORT_TMPL_DIR.'/devices/'."{$sname}-ports.tmpl");                      @symlink(PORT_PROFILE_DIR.'/'.$exp[$sname], PORT_TMPL_DIR.'/devices/'."{$sname}-ports.tmpl");
# Line 165  if (isset($_REQUEST['submit_top']) || is Line 168  if (isset($_REQUEST['submit_top']) || is
168                      @unlink(PORT_TMPL_DIR.'/devices/'."{$sname}-ports.tmpl");                      @unlink(PORT_TMPL_DIR.'/devices/'."{$sname}-ports.tmpl");
169                  }                  }
170              }              }
171              $now = time();          }
172              $sql = 'UPDATE SYS_PROPERTIES SET value=? WHERE name=?';      }
173              try {      if ($made_change) {
174                  $sth = $dbh->prepare($sql);          $now = time();
175                  $sth->execute([$now, 'last_logic_update']);          $sql = 'UPDATE SYS_PROPERTIES SET value=? WHERE name=?';
176                  $sth->closeCursor();          try {
177                  $logger->info("User {$ruser} updated the last logic date");              $sth = $dbh->prepare($sql);
178              } catch (PDOException $e) {              $sth->execute([$now, 'last_logic_update']);
179                  array_push($errors, "Failed to update the last logic update date: '{$e->getMessage()}'");              $sth->closeCursor();
180              }              $logger->info("User {$ruser} updated the last logic date");
181            } catch (PDOException $e) {
182                array_push($errors, "Failed to update the last logic update date: '{$e->getMessage()}'");
183          }          }
184      }      }
185  }  }
# Line 338  foreach ($MDFS as $m) { Line 343  foreach ($MDFS as $m) {
343      ?>      ?>
344                 <option value="<?=$_SERVER['PHP_SELF']?>?filter=<?=$m?>" <?=($filter == $m) ? 'selected' : ''?>><?=$m?></option>                 <option value="<?=$_SERVER['PHP_SELF']?>?filter=<?=$m?>" <?=($filter == $m) ? 'selected' : ''?>><?=$m?></option>
345  <?php  <?php
   
346  }  }
347  ?>  ?>
348                 <option value="<?=$_SERVER['PHP_SELF']?>?filter=u" <?=($filter == 'u') ? 'selected' : ''?>>No IP Assigned</option>                 <option value="<?=$_SERVER['PHP_SELF']?>?filter=u" <?=($filter == 'u') ? 'selected' : ''?>>No IP Assigned</option>
# Line 347  foreach ($ZTP_PIDS as $spid) { Line 351  foreach ($ZTP_PIDS as $spid) {
351      $selected = ($filter == "pid:$spid") ? 'selected' : ''; ?>      $selected = ($filter == "pid:$spid") ? 'selected' : ''; ?>
352                 <option value="<?=$_SERVER['PHP_SELF']?>?filter=pid:<?=$spid?>" <?=$selected?>><?=$spid?></option>                 <option value="<?=$_SERVER['PHP_SELF']?>?filter=pid:<?=$spid?>" <?=$selected?>><?=$spid?></option>
353  <?php  <?php
   
354  }  }
355  ?>  ?>
356             </select></td>             </select></td>
# Line 373  foreach ($ZTP_PIDS as $spid) { Line 376  foreach ($ZTP_PIDS as $spid) {
376              ?>              ?>
377            <input type="hidden" name="<?=$name?>" value="<?=$value?>">            <input type="hidden" name="<?=$name?>" value="<?=$value?>">
378  <?php  <?php
   
379          }          }
380      }      }
381  ?>  ?>
# Line 392  foreach ($errors as $error) { Line 394  foreach ($errors as $error) {
394      ?>      ?>
395            <p class="error"><?=$error?></p>            <p class="error"><?=$error?></p>
396  <?php  <?php
   
397  }  }
398  ?>  ?>
399          </div>          </div>
# Line 434  foreach ($switches as $row) { Line 435  foreach ($switches as $row) {
435              ?>              ?>
436                <option value="__BOGUS__" <?=$selected?>>--Please Select--</option>                <option value="__BOGUS__" <?=$selected?>>--Please Select--</option>
437  <?php  <?php
   
438          } else {          } else {
439              ?>              ?>
440                <option value="<?=$p?>" <?=$selected?>><?=$p?></option>                <option value="<?=$p?>" <?=$selected?>><?=$p?></option>
441  <?php  <?php
   
442          }          }
443      } ?>      } ?>
444              </select></td>              </select></td>
# Line 468  foreach ($switches as $row) { Line 467  foreach ($switches as $row) {
467          } ?>          } ?>
468                <option value="<?=$path?>" <?=$selected?>><?=$exname?></option>                <option value="<?=$path?>" <?=$selected?>><?=$exname?></option>
469  <?php  <?php
   
470      } ?>      } ?>
471          </select>&nbsp;<a href="#" onClick='var pp = document.getElementById("exception_<?=$name?>"); if (pp.value == "__BOGUS__") { alert("There is no port profile associated to this logical switch."); return false; } else { window.open("<?=$base?>/show_config.php?type=profile&cfg=" + pp.value + "&dname=<?=$name?>", "Config for profile " + pp.value, "height=650,width=980"); return false; }'><img src="/images/mag.gif" border="0" title="View port profile"></td>          </select>&nbsp;<a href="#" onClick='var pp = document.getElementById("exception_<?=$name?>"); if (pp.value == "__BOGUS__") { alert("There is no port profile associated to this logical switch."); return false; } else { window.open("<?=$base?>/show_config.php?type=profile&cfg=" + pp.value + "&dname=<?=$name?>", "Config for profile " + pp.value, "height=650,width=980"); return false; }'><img src="/images/mag.gif" border="0" title="View port profile"></td>
472            </tr>            </tr>

Legend:
Removed from v.20638  
changed lines
  Added in v.20639

  ViewVC Help
Powered by ViewVC 1.1.27