Location: PHPKode > scripts > SRESI > share/php/sresi.php
<?php
  $sresi = "/usr/bin/sresi-php";

  switch($_POST['run'])
  {
    case "Load" :
      move_uploaded_file($_FILES['Lfichier']['tmp_name'], $_POST['data']);
      passthru($sresi . " --import " . $_POST['data'] . " as " .
        $_POST['Lformat'] . " --dump " . $_POST['data']);
      echo "<html>
  <head>
    <title>The SRESI Bookmarks Manager</title>
  </head>
  <frameset cols=\"25%,75%\">
    <frame name=\"control\" src=\"control.php?data=" .
      urlencode($_POST['data']) .
      "\" marginwidth=\"10\" marginheight=\"10\">
    <frame name=\"result\" src=\"blank.html\" marginwidth=\"10\" marginheight=\"10\">
  </frameset>
  <noframes>This is a proof-of-concept page: it needs frames,
  if only because it is easier than the alternatives</noframes>
</html>";
      break;

// Data display
    case "Display" :
      switch($_POST['format'])
      {
        case "cloud" :
          passthru($sresi . " --restore " . $_POST['data'] .
            " --php-cloud " . $_POST['data'] . " folder 0 " .
            " --dump " . $_POST['data']);
          break;
        case "portal" :
          passthru($sresi . " --restore " . $_POST['data'] .
            " --php-portal " . $_POST['data'] . " folder 0 " .
            " --dump " . $_POST['data']);
          break;
        case "dsv" :
        case "opera" :
          echo "<pre>";
          passthru($sresi . " --restore " . $_POST['data'] .
            " --export default " . $_POST['format'] .
            " --dump " . $_POST['data']);
          echo "</pre>";
          break;
        default :
          passthru($sresi . " --restore " . $_POST['data'] .
            " --export default " . $_POST['format'] .
            " --dump " . $_POST['data']);
          break;
      }
      break;
    case "Balance" :
      passthru($sresi . " --restore " . $_POST['data'] .
        " --balance --dump " . $_POST['data']);
      break;

// Information
    case "Statistics" :
      passthru($sresi . " --restore " . $_POST['data'] . " --stats ");
      break;
    case "Tags List" :
      passthru($sresi . " --restore " . $_POST['data'] . " -tl");
      break;
    case "Tags Count" :
      passthru($sresi . " --restore " . $_POST['data'] . " -tc");
      break;
    case "Hints List" :
      passthru($sresi . " --restore " . $_POST['data'] . " -hl");
      break;
    case "Shortcuts List" :
      passthru($sresi . " --restore " . $_POST['data'] . " -sl");
      break;

// Views Management
    case "Set View" :
      passthru($sresi . " --restore " . $_POST['data'] .
        " --set-view '" . $_POST['Vpattern'] .
        "' --dump " . $_POST['data']);
      break;
    case "Rollback View" :
      passthru($sresi . " --restore " . $_POST['data'] . 
        " --unset-views " . $_POST['Vnumber'] .
        " --dump " . $_POST['data']);
      break;
    case "Filter On View" :
      passthru($sresi . " --restore " . $_POST['data'] .
        " --filter-on-view --dump " . $_POST['data']);
      break;

// Cloud Management
    case "Exit Cloud" :
      passthru($sresi . " --restore " . $_POST['data'] .
        " --exit-cloud --dump " . $_POST['data']);
      break;
    case "Filter On Cloud" :
      passthru($sresi . " --restore " . $_POST['data'] .
        " --filter-on-cloud --dump " . $_POST['data']);
      break;

// Mass operations
    case "Selection" :
      passthru($sresi . " --restore " . $_POST['data'] . " --filter-bookmarks '" .
        $_POST['selection'] . "' --dump " . $_POST['data']);
      break;
    case "Merge" :
      passthru($sresi . " --restore " . $_POST['data'] . " --merge " .
        $_FILES['Mfichier']['tmp_name'] . " as " . $_POST['Mformat'] .
        " --dump " . $_POST['data']);
      unlink($_FILES['Mfichier']['tmp_name']);
      break;

// Bookmarks
    case "Add Bookmark" :
      passthru($sresi . " --restore " . $_POST['data'] . " -ba " .
        $_POST['BAtitre'] . " '" . $_POST['BAadresse'] . "' '" .
        $_POST['BAclefs'] . "' --dump " . $_POST['data']);
      break;
    case "Rename Bookmark" :
      passthru($sresi . " --restore " . $_POST['data'] . " -br '" .
        $_POST['BEsignet'] . "' to '" . $_POST['BEmaj'] .
        "' --dump " . $_POST['data']);
      break;
    case "Update Bookmark" :
      passthru($sresi . " --restore " . $_POST['data'] . " -bu '" .
        $_POST['BEsignet'] . "' to '" . $_POST['BEmaj'] .
        "' --dump " . $_POST['data']);
      break;
    case "Delete Bookmarks" :
      passthru($sresi . " --restore " . $_POST['data'] . " -bd '" .
        $_POST['DBsignets'] . "' --dump " . $_POST['data']);
      break;
    case "Confirm Deletion" :
      passthru($sresi . " --restore " . $_POST['data'] .
      " -bc --dump " . $_POST['data']);
      break;

// Hints
    case "Extend Hint" :
      passthru($sresi . " --restore " . $_POST['data'] . " -ha '" .
        $_POST['Hclef'] . "' with '" . $_POST['Hclefs'] .
        "' --dump " . $_POST['data']);
      break;
    case "Limit Hint" :
      passthru($sresi . " --restore " . $_POST['data'] . " -hr '" .
        $_POST['Hclefs'] . "' from '" . $_POST['Hclef'] .
        "' --dump " . $_POST['data']);
      break;
    case "Delete Hint" :
      passthru($sresi . " --restore " . $_POST['data'] . " -hd '" .
        $_POST['HDclef'] . "' --dump " . $_POST['data']);
      break;
    case "Extend Root Hint" :
      passthru($sresi . " --restore " . $_POST['data'] . " -ra '" .
        $_POST['HRclefs'] . "' --dump " . $_POST['data']);
      break;
    case "Limit Root Hint" :
      passthru($sresi . " --restore " . $_POST['data'] . " -rr '" .
        $_POST['HRclefs'] . "' --dump " . $_POST['data']);
      break;
    case "Delete Root Hint" :
      passthru($sresi . " --restore " . $_POST['data'] .
        " -rd --dump " . $_POST['data']);
      break;

// Shortcuts
    case "Extend Shortcut" :
      passthru($sresi . " --restore " . $_POST['data'] . " -sa '" .
        $_POST['Sclef'] . "' with '" . $_POST['Sclefs'] .
        "' --dump " . $_POST['data']);
      break;
    case "Limit Shortcut" :
      passthru($sresi . " --restore " . $_POST['data'] . " -sr '" .
        $_POST['Sclefs'] . "' from '" . $_POST['Sclef'] .
        "' --dump " . $_POST['data']);
      break;
    case "Delete Shortcut" :
      passthru($sresi . " --restore " . $_POST['data'] . " -sd '" .
        $_POST['SDclef'] . "' --dump " . $_POST['data']);
      break;

// Tags
    case "Add Tags" :
      passthru($sresi . " --restore " . $_POST['data'] . " -ta '" .
        $_POST['Tclefs'] . "' in '" . $_POST['Tsignets'] .
        "' --dump " . $_POST['data']);
      break;
    case "Delete Tags" :
      passthru($sresi . " --restore " . $_POST['data'] . " -td '" .
        $_POST['Tclefs'] . "' in '" . $_POST['Tsignets'] .
        "' --dump " . $_POST['data']);
      break;
    case "Swap Tags" :
      passthru($sresi . " --restore " . $_POST['data'] . " -ts '" .
        $_POST['TSoriginaux'] . "' to '" . $_POST['TSnouveaux'] .
        "' in '" . $_POST['TSsignets'] . "' --dump " . $_POST['data']);
      break;
    case "Rename Tag" :
      passthru($sresi . " --restore " . $_POST['data'] . " -tr '" .
        $_POST['TRoriginal'] . "' to '" . $_POST['TRnouveau'] .
        "' --dump " . $_POST['data']);
      break;

// Program control
    case "Undo" :
      passthru($sresi . " --restore " . $_POST['data'] .
        " --undo --dump " . $_POST['data']);
      break;
    case "Redo" :
      passthru($sresi . " --restore " . $_POST['data'] .
        " --redo --dump " . $_POST['data']);
      break;
    case "Exit" :
      passthru("rm -f " . $_POST['data']);
      break;

// Portal edition
    case "Add Bookmark Here" :
      passthru($sresi . " --restore " . $_POST['data'] . " -ba '" .
        $_POST['BAFtitre'] . "' '" . $_POST['BAFadresse'] . "' '" .
        $_POST['BAFclefs'] . ", " . $_POST['BAFlocales'] .
        "' --dump " . $_POST['data']);
      break;
    case "Swap Current Tags" :
      passthru($sresi . " --restore " . $_POST['data'] . " -ts '" .
        $_POST['BAFlocales'] . "' to '" . $_POST['BAFremplacements'] .
        "' --dump " . $_POST['data']);
      break;
    case "Rename" :
      passthru($sresi . " --restore " . $_POST['data'] . " -br '" .
        $_POST['Bident'] . "' to '" . $_POST['Bentree'] .
        "' --dump " . $_POST['data']);
      break;
    case "Update" :
      passthru($sresi . " --restore " . $_POST['data'] . " -bu '" .
        $_POST['Bident'] . "' to '" . $_POST['Bentree'] .
        "' --dump " . $_POST['data']);
      break;
    case "Delete It" :
      passthru($sresi . " --restore " . $_POST['data'] . " -bd '< " .
        $_POST['Bident'] . " >' --dump " . $_POST['data']);
      break;
    case "Add" :
      passthru($sresi . " --restore " . $_POST['data'] . " -ta '" .
        $_POST['Bentree'] . "' in '< " . $_POST['Bident'] .
        " >' --dump " . $_POST['data']);
      break;
    case "Remove" :
      passthru($sresi . " --restore " . $_POST['data'] . " -td '" .
        $_POST['Bentree'] . "' in '< " . $_POST['Bident'] .
        " >' --dump " . $_POST['data']);
      break;
    case "Replace" :
      passthru($sresi . " --restore " . $_POST['data'] . " -ts '" .
        $_POST['Bclefs'] . "' to '" . $_POST['Bentree'] .
        "' in '< " . $_POST['Bident'] . " >' --dump " . $_POST['data']);
      break;

// TODO(PHP displays): Can be factorised with better calls from the program.
    default :
      switch($_GET['run'])
      {
        case "extend-cloud" :
          passthru($sresi . " --restore " . $_GET['data'] .
            " --extend-cloud '" . $_GET['tag'] .
            "' --dump " . $_GET['data']);
          break;
        case "refine-cloud" :
          passthru($sresi . " --restore " . $_GET['data'] .
            " --refine-cloud '" . $_GET['tag'] .
            "' --dump " . $_GET['data']);
          break;
        case "exit-cloud" :
          passthru($sresi . " --restore " . $_GET['data'] .
            " --exit-cloud --dump " . $_GET['data']);
          break;

        case "cloud-fldr" :
          passthru($sresi . " --restore " . $_GET['data'] .
            " --php-cloud " . $_GET['data'] .  " folder " . $_GET['id'] .
            " --dump " . $_GET['data']);
          break;
        case "cloud-bmk" :
          passthru($sresi . " --restore " . $_GET['data'] .
            " --php-cloud " . $_GET['data'] .  " bookmark " . $_GET['id'] .
            " --dump " . $_GET['data']);
          break;
        case "php-fldr" :
          passthru($sresi . " --restore " . $_GET['data'] .
            " --php-portal " . $_GET['data'] .  " folder " . $_GET['id'] .
            " --dump " . $_GET['data']);
          break;
        case "php-bmk" :
          passthru($sresi . " --restore " . $_GET['data'] .
            " --php-portal " . $_GET['data'] .  " bookmark " . $_GET['id'] .
            " --dump " . $_GET['data']);
          break;

      };

  };
?>
Return current item: SRESI