Simple Groupware PHP Cross Reference Groupware Applications

Source: /src/lib/browser/browser.php - 2480 lines - 66705 bytes - Summary - Text - Print

   1  <?php
   2  if (!defined("MAIN_SCRIPT")) exit;
   3  @error_reporting(E_ALL & ~E_NOTICE);
   4  
   5  if (!sys_is_super_admin($_SESSION["username"])) sys_die("Not allowed. Please log in as super administrator.");
   6  
   7  if ((!empty($_GET) or !empty($_POST)) and !array_key_exists($_REQUEST["token"],$_SESSION["tokens"])) sys_die("Invalid security token.");
   8  
   9  $token = md5(uniqid(rand(),true));
  10  $_SESSION["tokens"][$token] = 1;
  11  
  12  /*
  13   * webadmin.php - a simple Web-based file manager
  14   * Copyright (C) 2004  Daniel Wacker <daniel.wacker@web.de>
  15   *
  16   * This program is free software; you can redistribute it and/or modify
  17   * it under the terms of the GNU General Public License as published by
  18   * the Free Software Foundation; either version 2 of the License, or
  19   * (at your option) any later version.
  20   *
  21   * This program is distributed in the hope that it will be useful,
  22   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24   * GNU General Public License for more details.
  25   *
  26   * You should have received a copy of the GNU General Public License
  27   * along with this program; if not, write to the Free Software
  28   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29   *
  30   * -------------------------------------------------------------------------
  31   * While using this script, do NOT navigate with your browser's back and
  32   * forward buttons! Always open files in a new browser tab!
  33   * -------------------------------------------------------------------------
  34   *
  35   * This is Version 0.9, revision 10
  36   * =========================================================================
  37   *
  38   * Changes of revision 10
  39   * <alex-smirnov@web.de>
  40   *    added Russian translation
  41   * <daniel.wacker@web.de>
  42   *    added </td> to achieve valid XHTML (thanks to Marc Magos)
  43   *    improved delete function
  44   * <ava@asl.se>
  45   *    new list order: folders first
  46   *
  47   * Changes of revision 9
  48   * <daniel.wacker@web.de>
  49   *    added workaround for directory listing, if lstat() is disabled
  50   *    fixed permisson of uploaded files (thanks to Stephan Duffner)
  51   *
  52   * Changes of revision 8
  53   * <okankan@stud.sdu.edu.tr>
  54   *    added Turkish translation
  55   * <j@kub.cz>
  56   *    added Czech translation
  57   * <daniel.wacker@web.de>
  58   *    improved charset handling
  59   *
  60   * Changes of revision 7
  61   * <szuniga@vtr.net>
  62   *    added Spanish translation
  63   * <lars@soelgaard.net>
  64   *    added Danish translation
  65   * <daniel.wacker@web.de>
  66   *    improved rename dialog
  67   *
  68   * Changes of revision 6
  69   * <nederkoorn@tiscali.nl>
  70   *    added Dutch translation
  71   *
  72   * Changes of revision 5
  73   * <daniel.wacker@web.de>
  74   *    added language auto select
  75   *    fixed symlinks in directory listing
  76   *    removed word-wrap in edit textarea
  77   *
  78   * Changes of revision 4
  79   * <daloan@guideo.fr>
  80   *    added French translation
  81   * <anders@wiik.cc>
  82   *    added Swedish translation
  83   *
  84   * Changes of revision 3
  85   * <nzunta@gabriele-erba.it>
  86   *    improved Italian translation
  87   *
  88   * Changes of revision 2
  89   * <daniel.wacker@web.de>
  90   *    got images work in some old browsers
  91   *    fixed creation of directories
  92   *    fixed files deletion
  93   *    improved path handling
  94   *    added missing word 'not_created'
  95   * <till@tuxen.de>
  96   *    improved human readability of file sizes
  97   * <nzunta@gabriele-erba.it>
  98   *    added Italian translation
  99   *
 100   * Changes of revision 1
 101   * <daniel.wacker@web.de>
 102   *    webadmin.php completely rewritten:
 103   *    - clean XHTML/CSS output
 104   *    - several files selectable
 105   *    - support for windows servers
 106   *    - no more treeview, because
 107   *      - webadmin.php is a >simple< file manager
 108   *      - performance problems (too much additional code)
 109   *      - I don't like: frames, java-script, to reload after every treeview-click
 110   *    - execution of shell scripts
 111   *    - introduced revision numbers
 112   *
 113  /* ------------------------------------------------------------------------- */
 114  
 115  /* Your language:
 116   * 'en' - English
 117   * 'de' - German
 118   * 'fr' - French
 119   * 'it' - Italian
 120   * 'nl' - Dutch
 121   * 'se' - Swedish
 122   * 'sp' - Spanish
 123   * 'dk' - Danish
 124   * 'tr' - Turkish
 125   * 'cs' - Czech
 126   * 'ru' - Russian
 127   * 'auto' - autoselect
 128   */
 129  $lang = 'auto';
 130  
 131  /* Charset of output:
 132   * possible values are described in the charset table at
 133   * http://www.php.net/manual/en/function.htmlentities.php
 134   * 'auto' - use the same charset as the words of my language are encoded
 135   */
 136  $site_charset = 'auto';
 137  
 138  /* Homedir:
 139   * For example: './' - the script's directory
 140   */
 141  $homedir = './';
 142  
 143  /* Size of the edit textarea
 144   */
 145  $editcols = 80;
 146  $editrows = 25;
 147  
 148  /* -------------------------------------------
 149   * Optional configuration (remove # to enable)
 150   */
 151  
 152  /* Permission of created directories:
 153   * For example: 0705 would be 'drwx---r-x'.
 154   */
 155  # $dirpermission = 0705;
 156  
 157  /* Permission of created files:
 158   * For example: 0604 would be '-rw----r--'.
 159   */
 160  # $filepermission = 0604;
 161  
 162  /* Filenames related to the apache web server:
 163   */
 164  $htaccess = '.htaccess';
 165  $htpasswd = '.htpasswd';
 166  
 167  /* ------------------------------------------------------------------------- */
 168  
 169  if (ini_get("magic_quotes_gpc")!==false and get_magic_quotes_gpc()) {
 170      array_walk($_GET, 'strip');
 171      array_walk($_POST, 'strip');
 172      array_walk($_REQUEST, 'strip');
 173  }
 174  
 175  if (array_key_exists('image', $_GET)) {
 176      header('Content-Type: image/gif');
 177      exit(getimage($_GET['image']));
 178  }
 179  
 180  if (!function_exists('lstat')) {
 181  	function lstat ($filename) {
 182          return stat($filename);
 183      }
 184  }
 185  
 186  $delim = DIRECTORY_SEPARATOR;
 187  
 188  if (function_exists('php_uname')) {
 189      $win = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false;
 190  } else {
 191      $win = ($delim == '\\') ? true : false;
 192  }
 193  
 194  if (!empty($_SERVER['SCRIPT_FILENAME'])) {
 195      $scriptdir = dirname($_SERVER['SCRIPT_FILENAME']);
 196  } elseif (function_exists('getcwd')) {
 197      $scriptdir = getcwd();
 198  } else {
 199      $scriptdir = '.';
 200  }
 201  $homedir = relative2absolute($homedir, $scriptdir);
 202  
 203  $dir = (array_key_exists('dir', $_REQUEST)) ? $_REQUEST['dir'] : $homedir;
 204  
 205  if (array_key_exists('olddir', $_POST) && !path_is_relative($_POST['olddir'])) {
 206      $dir = relative2absolute($dir, $_POST['olddir']);
 207  }
 208  
 209  $directory = simplify_path(addslash($dir));
 210  
 211  $files = array();
 212  $action = '';
 213  if (!empty($_POST['submit_all'])) {
 214      $action = $_POST['action_all'];
 215      for ($i = 0; $i < $_POST['num']; $i++) {
 216          if (array_key_exists("checked$i", $_POST) && $_POST["checked$i"] == 'true') {
 217              $files[] = $_POST["file$i"];
 218          }
 219      }
 220  } elseif (!empty($_REQUEST['action'])) {
 221      $action = $_REQUEST['action'];
 222      $files[] = relative2absolute($_REQUEST['file'], $directory);
 223  } elseif (!empty($_POST['submit_upload']) && !empty($_FILES['upload']['name'])) {
 224      $files[] = $_FILES['upload'];
 225      $action = 'upload';
 226  } elseif (array_key_exists('num', $_POST)) {
 227      for ($i = 0; $i < $_POST['num']; $i++) {
 228          if (array_key_exists("submit$i", $_POST)) break;
 229      }
 230      if ($i < $_POST['num']) {
 231          $action = $_POST["action$i"];
 232          $files[] = $_POST["file$i"];
 233      }
 234  }
 235  if (empty($action) && (!empty($_POST['submit_create']) || (array_key_exists('focus', $_POST) && $_POST['focus'] == 'create')) && !empty($_POST['create_name'])) {
 236      $files[] = relative2absolute($_POST['create_name'], $directory);
 237      switch ($_POST['create_type']) {
 238      case 'directory':
 239          $action = 'create_directory';
 240          break;
 241      case 'file':
 242          $action = 'create_file';
 243      }
 244  }
 245  if (sizeof($files) == 0) $action = ''; else $file = reset($files);
 246  
 247  if ($lang == 'auto') {
 248      if (array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
 249          $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
 250      } else {
 251          $lang = 'en';
 252      }
 253  }
 254  
 255  $words = getwords($lang);
 256  
 257  if ($site_charset == 'auto') {
 258      $site_charset = $word_charset;
 259  }
 260  
 261  $cols = 9;
 262  
 263  if (!isset($dirpermission)) {
 264      $dirpermission = (function_exists('umask')) ? (0777 & ~umask()) : 0755;
 265  }
 266  if (!isset($filepermission)) {
 267      $filepermission = (function_exists('umask')) ? (0666 & ~umask()) : 0644;
 268  }
 269  
 270  if (!empty($_SERVER['SCRIPT_NAME'])) {
 271      $self = html(basename($_SERVER['SCRIPT_NAME']));
 272  } elseif (!empty($_SERVER['PHP_SELF'])) {
 273      $self = html(basename($_SERVER['PHP_SELF']));
 274  } else {
 275      $self = '';
 276  }
 277  $self .= "?token=".$token;
 278  
 279  if (!empty($_SERVER['SERVER_SOFTWARE'])) {
 280      if (strtolower(substr($_SERVER['SERVER_SOFTWARE'], 0, 6)) == 'apache') {
 281          $apache = true;
 282      } else {
 283          $apache = false;
 284      }
 285  } else {
 286      $apache = true;
 287  }
 288  
 289  switch ($action) {
 290  
 291  case 'view':
 292  
 293      if (is_script($file)) {
 294  
 295          /* highlight_file is a mess! */
 296          ob_start();
 297          highlight_file($file);
 298          $src = ereg_replace('<font color="([^"]*)">', '<span style="color: \1">', ob_get_contents());
 299          $src = str_replace(array('</font>', "\r", "\n"), array('</span>', '', ''), $src);
 300          ob_end_clean();
 301  
 302          html_header();
 303          echo '<h2 style="text-align: left; margin-bottom: 0">' . html($file) . '</h2>
 304  
 305  <hr />
 306  
 307  <table>
 308  <tr>
 309  <td style="text-align: right; vertical-align: top; color: gray; padding-right: 3pt; border-right: 1px solid gray">
 310  <pre style="margin-top: 0"><code>';
 311  
 312          for ($i = 1; $i <= sizeof(file($file)); $i++) echo "$i\n";
 313  
 314          echo '</code></pre>
 315  </td>
 316  <td style="text-align: left; vertical-align: top; padding-left: 3pt">
 317  <pre style="margin-top: 0">' . $src . '</pre>
 318  </td>
 319  </tr>
 320  </table>
 321  
 322  ';
 323  
 324          html_footer();
 325  
 326      } else {
 327  
 328          header('Content-Type: ' . getmimetype($file) . '; charset=utf-8');
 329          header('Content-Disposition: filename=' . basename($file));
 330  
 331          readfile($file);
 332  
 333      }
 334  
 335      break;
 336  
 337  case 'download':
 338  
 339      header('Pragma: public');
 340      header('Expires: 0');
 341      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
 342      header('Content-Type: ' . getmimetype($file) . '; charset=utf-8');
 343      header('Content-Disposition: attachment; filename=' . basename($file) . ';');
 344      header('Content-Length: ' . filesize($file));
 345      
 346      readfile($file);
 347  
 348      break;
 349  
 350  case 'upload':
 351  
 352      $dest = relative2absolute($file['name'], $directory);
 353  
 354      if (@file_exists($dest)) {
 355          listing_page(error('already_exists', $dest));
 356      } elseif (@move_uploaded_file($file['tmp_name'], $dest)) {
 357          @chmod($dest, $filepermission);
 358          listing_page(notice('uploaded', $file['name']));
 359      } else {
 360          listing_page(error('not_uploaded', $file['name']));
 361      }
 362  
 363      break;
 364  
 365  case 'create_directory':
 366  
 367      if (@file_exists($file)) {
 368          listing_page(error('already_exists', $file));
 369      } else {
 370          $old = @umask(0777 & ~$dirpermission);
 371          if (@mkdir($file, $dirpermission)) {
 372              listing_page(notice('created', $file));
 373          } else {
 374              listing_page(error('not_created', $file));
 375          }
 376          @umask($old);
 377      }
 378  
 379      break;
 380  
 381  case 'create_file':
 382  
 383      if (@file_exists($file)) {
 384          listing_page(error('already_exists', $file));
 385      } else {
 386          $old = @umask(0777 & ~$filepermission);
 387          if (@touch($file)) {
 388              edit($file);
 389          } else {
 390              listing_page(error('not_created', $file));
 391          }
 392          @umask($old);
 393      }
 394  
 395      break;
 396  
 397  case 'execute':
 398  
 399      chdir(dirname($file));
 400  
 401      $output = array();
 402      $retval = 0;
 403      exec('echo "./' . basename($file) . '" | /bin/sh', $output, $retval);
 404  
 405      $error = ($retval == 0) ? false : true;
 406  
 407      if (sizeof($output) == 0) $output = array('<' . $words['no_output'] . '>');
 408  
 409      if ($error) {
 410          listing_page(error('not_executed', $file, implode("\n", $output)));
 411      } else {
 412          listing_page(notice('executed', $file, implode("\n", $output)));
 413      }
 414  
 415      break;
 416  
 417  case 'delete':
 418  
 419      if (!empty($_POST['no'])) {
 420          listing_page();
 421      } elseif (!empty($_POST['yes'])) {
 422  
 423          $failure = array();
 424          $success = array();
 425  
 426          foreach ($files as $file) {
 427              if (del($file)) {
 428                  $success[] = $file;
 429              } else {
 430                  $failure[] = $file;
 431              }
 432          }
 433  
 434          $message = '';
 435          if (sizeof($failure) > 0) {
 436              $message = error('not_deleted', implode("\n", $failure));
 437          }
 438          if (sizeof($success) > 0) {
 439              $message .= notice('deleted', implode("\n", $success));
 440          }
 441  
 442          listing_page($message);
 443  
 444      } else {
 445  
 446          html_header();
 447  
 448          echo '<form action="' . $self . '" method="post">
 449  <table class="dialog">
 450  <tr>
 451  <td class="dialog">
 452  ';
 453  
 454          request_dump();
 455  
 456          echo "\t<b>" . word('really_delete') . '</b>
 457      <p>
 458  ';
 459  
 460          foreach ($files as $file) {
 461              echo "\t" . html($file) . "<br />\n";
 462          }
 463  
 464          echo '    </p>
 465      <hr />
 466      <input type="submit" name="no" value="' . word('no') . '" id="red_button" />
 467      <input type="submit" name="yes" value="' . word('yes') . '" id="green_button" style="margin-left: 50px" />
 468  </td>
 469  </tr>
 470  </table>
 471  </form>
 472  
 473  ';
 474  
 475          html_footer();
 476  
 477      }
 478  
 479      break;
 480  
 481  case 'rename':
 482  
 483      if (!empty($_POST['destination'])) {
 484  
 485          $dest = relative2absolute($_POST['destination'], $directory);
 486  
 487          if (!@file_exists($dest) && @rename($file, $dest)) {
 488              listing_page(notice('renamed', $file, $dest));
 489          } else {
 490              listing_page(error('not_renamed', $file, $dest));
 491          }
 492  
 493      } else {
 494  
 495          $name = basename($file);
 496  
 497          html_header();
 498  
 499          echo '<form action="' . $self . '" method="post">
 500  
 501  <table class="dialog">
 502  <tr>
 503  <td class="dialog">
 504      <input type="hidden" name="action" value="rename" />
 505      <input type="hidden" name="file" value="' . html($file) . '" />
 506      <input type="hidden" name="dir" value="' . html($directory) . '" />
 507      <b>' . word('rename_file') . '</b>
 508      <p>' . html($file) . '</p>
 509      <b>' . substr($file, 0, strlen($file) - strlen($name)) . '</b>
 510      <input type="text" name="destination" size="' . textfieldsize($name) . '" value="' . html($name) . '" />
 511      <hr />
 512      <input type="submit" value="' . word('rename') . '" />
 513  </td>
 514  </tr>
 515  </table>
 516  
 517  <p><a href="' . $self . '&dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
 518  
 519  </form>
 520  
 521  ';
 522  
 523          html_footer();
 524  
 525      }
 526  
 527      break;
 528  
 529  case 'move':
 530  
 531      if (!empty($_POST['destination'])) {
 532  
 533          $dest = relative2absolute($_POST['destination'], $directory);
 534  
 535          $failure = array();
 536          $success = array();
 537  
 538          foreach ($files as $file) {
 539              $filename = substr($file, strlen($directory));
 540              $d = $dest . $filename;
 541              if (!@file_exists($d) && @rename($file, $d)) {
 542                  $success[] = $file;
 543              } else {
 544                  $failure[] = $file;
 545              }
 546          }
 547  
 548          $message = '';
 549          if (sizeof($failure) > 0) {
 550              $message = error('not_moved', implode("\n", $failure), $dest);
 551          }
 552          if (sizeof($success) > 0) {
 553              $message .= notice('moved', implode("\n", $success), $dest);
 554          }
 555  
 556          listing_page($message);
 557  
 558      } else {
 559  
 560          html_header();
 561  
 562          echo '<form action="' . $self . '" method="post">
 563  
 564  <table class="dialog">
 565  <tr>
 566  <td class="dialog">
 567  ';
 568  
 569          request_dump();
 570  
 571          echo "\t<b>" . word('move_files') . '</b>
 572      <p>
 573  ';
 574  
 575          foreach ($files as $file) {
 576              echo "\t" . html($file) . "<br />\n";
 577          }
 578  
 579          echo '    </p>
 580      <hr />
 581      ' . word('destination') . ':
 582      <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
 583      <input type="submit" value="' . word('move') . '" />
 584  </td>
 585  </tr>
 586  </table>
 587  
 588  <p><a href="' . $self . '&dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
 589  
 590  </form>
 591  
 592  ';
 593  
 594          html_footer();
 595  
 596      }
 597  
 598      break;
 599  
 600  case 'copy':
 601  
 602      if (!empty($_POST['destination'])) {
 603  
 604          $dest = relative2absolute($_POST['destination'], $directory);
 605  
 606          if (@is_dir($dest)) {
 607  
 608              $failure = array();
 609              $success = array();
 610  
 611              foreach ($files as $file) {
 612                  $filename = substr($file, strlen($directory));
 613                  $d = addslash($dest) . $filename;
 614                  if (!@is_dir($file) && !@file_exists($d) && @copy($file, $d)) {
 615                      $success[] = $file;
 616                  } else {
 617                      $failure[] = $file;
 618                  }
 619              }
 620  
 621              $message = '';
 622              if (sizeof($failure) > 0) {
 623                  $message = error('not_copied', implode("\n", $failure), $dest);
 624              }
 625              if (sizeof($success) > 0) {
 626                  $message .= notice('copied', implode("\n", $success), $dest);
 627              }
 628  
 629              listing_page($message);
 630  
 631          } else {
 632  
 633              if (!@file_exists($dest) && @copy($file, $dest)) {
 634                  listing_page(notice('copied', $file, $dest));
 635              } else {
 636                  listing_page(error('not_copied', $file, $dest));
 637              }
 638  
 639          }
 640  
 641      } else {
 642  
 643          html_header();
 644  
 645          echo '<form action="' . $self . '" method="post">
 646  
 647  <table class="dialog">
 648  <tr>
 649  <td class="dialog">
 650  ';
 651  
 652          request_dump();
 653  
 654          echo "\n<b>" . word('copy_files') . '</b>
 655      <p>
 656  ';
 657  
 658          foreach ($files as $file) {
 659              echo "\t" . html($file) . "<br />\n";
 660          }
 661  
 662          echo '    </p>
 663      <hr />
 664      ' . word('destination') . ':
 665      <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
 666      <input type="submit" value="' . word('copy') . '" />
 667  </td>
 668  </tr>
 669  </table>
 670  
 671  <p><a href="' . $self . '&dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
 672  
 673  </form>
 674  
 675  ';
 676  
 677          html_footer();
 678  
 679      }
 680  
 681      break;
 682  
 683  case 'create_symlink':
 684  
 685      if (!empty($_POST['destination'])) {
 686  
 687          $dest = relative2absolute($_POST['destination'], $directory);
 688  
 689          if (substr($dest, -1, 1) == $delim) $dest .= basename($file);
 690  
 691          if (!empty($_POST['relative'])) $file = absolute2relative(addslash(dirname($dest)), $file);
 692  
 693          if (!@file_exists($dest) && @symlink($file, $dest)) {
 694              listing_page(notice('symlinked', $file, $dest));
 695          } else {
 696              listing_page(error('not_symlinked', $file, $dest));
 697          }
 698  
 699      } else {
 700  
 701          html_header();
 702  
 703          echo '<form action="' . $self . '" method="post">
 704  
 705  <table class="dialog" id="symlink">
 706  <tr>
 707      <td style="vertical-align: top">' . word('destination') . ': </td>
 708      <td>
 709          <b>' . html($file) . '</b><br />
 710          <input type="checkbox" name="relative" value="yes" id="checkbox_relative" checked="checked" style="margin-top: 1ex" />
 711          <label for="checkbox_relative">' . word('relative') . '</label>
 712          <input type="hidden" name="action" value="create_symlink" />
 713          <input type="hidden" name="file" value="' . html($file) . '" />
 714          <input type="hidden" name="dir" value="' . html($directory) . '" />
 715      </td>
 716  </tr>
 717  <tr>
 718      <td>' . word('symlink') . ': </td>
 719      <td>
 720          <input type="text" name="destination" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" />
 721          <input type="submit" value="' . word('create_symlink') . '" />
 722      </td>
 723  </tr>
 724  </table>
 725  
 726  <p><a href="' . $self . '&dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
 727  
 728  </form>
 729  
 730  ';
 731  
 732          html_footer();
 733  
 734      }
 735  
 736      break;
 737  
 738  case 'edit':
 739  
 740      if (!empty($_POST['save'])) {
 741  
 742          $content = str_replace("\r\n", "\n", $_POST['content']);
 743  
 744          if (($f = @fopen($file, 'w')) && @fwrite($f, $content) !== false && @fclose($f)) {
 745              listing_page(notice('saved', $file));
 746          } else {
 747              listing_page(error('not_saved', $file));
 748          }
 749  
 750      } else {
 751  
 752          if (@is_readable($file) && @is_writable($file)) {
 753              edit($file);
 754          } else {
 755              listing_page(error('not_edited', $file));
 756          }
 757  
 758      }
 759  
 760      break;
 761  
 762  case 'permission':
 763  
 764      if (!empty($_POST['set'])) {
 765  
 766          $mode = 0;
 767          if (!empty($_POST['ur'])) $mode |= 0400; if (!empty($_POST['uw'])) $mode |= 0200; if (!empty($_POST['ux'])) $mode |= 0100;
 768          if (!empty($_POST['gr'])) $mode |= 0040; if (!empty($_POST['gw'])) $mode |= 0020; if (!empty($_POST['gx'])) $mode |= 0010;
 769          if (!empty($_POST['or'])) $mode |= 0004; if (!empty($_POST['ow'])) $mode |= 0002; if (!empty($_POST['ox'])) $mode |= 0001;
 770  
 771          if (@chmod($file, $mode)) {
 772              listing_page(notice('permission_set', $file, decoct($mode)));
 773          } else {
 774              listing_page(error('permission_not_set', $file, decoct($mode)));
 775          }
 776  
 777      } else {
 778  
 779          html_header();
 780  
 781          $mode = fileperms($file);
 782  
 783          echo '<form action="' . $self . '" method="post">
 784  
 785  <table class="dialog">
 786  <tr>
 787  <td class="dialog">
 788  
 789      <p style="margin: 0">' . phrase('permission_for', $file) . '</p>
 790  
 791      <hr />
 792  
 793      <table id="permission">
 794      <tr>
 795          <td></td>
 796          <td style="border-right: 1px solid black">' . word('owner') . '</td>
 797          <td style="border-right: 1px solid black">' . word('group') . '</td>
 798          <td>' . word('other') . '</td>
 799      </tr>
 800      <tr>
 801          <td style="text-align: right">' . word('read') . ':</td>
 802          <td><input type="checkbox" name="ur" value="1"'; if ($mode & 00400) echo ' checked="checked"'; echo ' /></td>
 803          <td><input type="checkbox" name="gr" value="1"'; if ($mode & 00040) echo ' checked="checked"'; echo ' /></td>
 804          <td><input type="checkbox" name="or" value="1"'; if ($mode & 00004) echo ' checked="checked"'; echo ' /></td>
 805      </tr>
 806      <tr>
 807          <td style="text-align: right">' . word('write') . ':</td>
 808          <td><input type="checkbox" name="uw" value="1"'; if ($mode & 00200) echo ' checked="checked"'; echo ' /></td>
 809          <td><input type="checkbox" name="gw" value="1"'; if ($mode & 00020) echo ' checked="checked"'; echo ' /></td>
 810          <td><input type="checkbox" name="ow" value="1"'; if ($mode & 00002) echo ' checked="checked"'; echo ' /></td>
 811      </tr>
 812      <tr>
 813          <td style="text-align: right">' . word('execute') . ':</td>
 814          <td><input type="checkbox" name="ux" value="1"'; if ($mode & 00100) echo ' checked="checked"'; echo ' /></td>
 815          <td><input type="checkbox" name="gx" value="1"'; if ($mode & 00010) echo ' checked="checked"'; echo ' /></td>
 816          <td><input type="checkbox" name="ox" value="1"'; if ($mode & 00001) echo ' checked="checked"'; echo ' /></td>
 817      </tr>
 818      </table>
 819  
 820      <hr />
 821  
 822      <input type="submit" name="set" value="' . word('set') . '" />
 823  
 824      <input type="hidden" name="action" value="permission" />
 825      <input type="hidden" name="file" value="' . html($file) . '" />
 826      <input type="hidden" name="dir" value="' . html($directory) . '" />
 827  
 828  </td>
 829  </tr>
 830  </table>
 831  
 832  <p><a href="' . $self . '&dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
 833  
 834  </form>
 835  
 836  ';
 837  
 838          html_footer();
 839  
 840      }
 841  
 842      break;
 843  
 844  default:
 845  
 846      listing_page();
 847  
 848  }
 849  
 850  /* ------------------------------------------------------------------------- */
 851  
 852  function getlist ($directory) {
 853      global $delim, $win;
 854  
 855      if ($d = @opendir($directory)) {
 856  
 857          while (($filename = @readdir($d)) !== false) {
 858  
 859              $path = $directory . $filename;
 860  
 861              if ($stat = @lstat($path)) {
 862  
 863                  $file = array(
 864                      'filename'    => $filename,
 865                      'path'        => $path,
 866                      'is_file'     => @is_file($path),
 867                      'is_dir'      => @is_dir($path),
 868                      'is_link'     => @is_link($path),
 869                      'is_readable' => @is_readable($path),
 870                      'is_writable' => @is_writable($path),
 871                      'size'        => $stat['size'],
 872                      'permission'  => $stat['mode'],
 873                      'owner'       => $stat['uid'],
 874                      'group'       => $stat['gid'],
 875                      'mtime'       => @filemtime($path),
 876                      'atime'       => @fileatime($path),
 877                      'ctime'       => @filectime($path)
 878                  );
 879  
 880                  if ($file['is_dir']) {
 881                      $file['is_executable'] = @file_exists($path . $delim . '.');
 882                  } else {
 883                      if (!$win) {
 884                          $file['is_executable'] = @is_executable($path);
 885                      } else {
 886                          $file['is_executable'] = true;
 887                      }
 888                  }
 889  
 890                  if ($file['is_link']) $file['target'] = @readlink($path);
 891  
 892                  if (function_exists('posix_getpwuid')) $file['owner_name'] = @reset(posix_getpwuid($file['owner']));
 893                  if (function_exists('posix_getgrgid')) $file['group_name'] = @reset(posix_getgrgid($file['group']));
 894  
 895                  $files[] = $file;
 896  
 897              }
 898  
 899          }
 900  
 901          return $files;
 902  
 903      } else {
 904          return false;
 905      }
 906  
 907  }
 908  
 909  function sortlist ($list, $key, $reverse) {
 910  
 911      $dirs = array();
 912      $files = array();
 913      
 914      for ($i = 0; $i < sizeof($list); $i++) {
 915          if ($list[$i]['is_dir']) $dirs[] = $list[$i];
 916          else $files[] = $list[$i];
 917      }
 918  
 919      quicksort($dirs, 0, sizeof($dirs) - 1, $key);
 920      if ($reverse) $dirs = array_reverse($dirs);
 921  
 922      quicksort($files, 0, sizeof($files) - 1, $key);
 923      if ($reverse) $files = array_reverse($files);
 924  
 925      return array_merge($dirs, $files);
 926  
 927  }
 928  
 929  function quicksort (&$array, $first, $last, $key) {
 930  
 931      if ($first < $last) {
 932  
 933          $cmp = $array[floor(($first + $last) / 2)][$key];
 934  
 935          $l = $first;
 936          $r = $last;
 937  
 938          while ($l <= $r) {
 939  
 940              while ($array[$l][$key] < $cmp) $l++;
 941              while ($array[$r][$key] > $cmp) $r--;
 942  
 943              if ($l <= $r) {
 944  
 945                  $tmp = $array[$l];
 946                  $array[$l] = $array[$r];
 947                  $array[$r] = $tmp;
 948  
 949                  $l++;
 950                  $r--;
 951  
 952              }
 953  
 954          }
 955  
 956          quicksort($array, $first, $r, $key);
 957          quicksort($array, $l, $last, $key);
 958  
 959      }
 960  
 961  }
 962  
 963  function permission_octal2string ($mode) {
 964  
 965      if (($mode & 0xC000) === 0xC000) {
 966          $type = 's';
 967      } elseif (($mode & 0xA000) === 0xA000) {
 968          $type = 'l';
 969      } elseif (($mode & 0x8000) === 0x8000) {
 970          $type = '-';
 971      } elseif (($mode & 0x6000) === 0x6000) {
 972          $type = 'b';
 973      } elseif (($mode & 0x4000) === 0x4000) {
 974          $type = 'd';
 975      } elseif (($mode & 0x2000) === 0x2000) {
 976          $type = 'c';
 977      } elseif (($mode & 0x1000) === 0x1000) {
 978          $type = 'p';
 979      } else {
 980          $type = '?';
 981      }
 982  
 983      $owner  = ($mode & 00400) ? 'r' : '-';
 984      $owner .= ($mode & 00200) ? 'w' : '-';
 985      if ($mode & 0x800) {
 986          $owner .= ($mode & 00100) ? 's' : 'S';
 987      } else {
 988          $owner .= ($mode & 00100) ? 'x' : '-';
 989      }
 990  
 991      $group  = ($mode & 00040) ? 'r' : '-';
 992      $group .= ($mode & 00020) ? 'w' : '-';
 993      if ($mode & 0x400) {
 994          $group .= ($mode & 00010) ? 's' : 'S';
 995      } else {
 996          $group .= ($mode & 00010) ? 'x' : '-';
 997      }
 998  
 999      $other  = ($mode & 00004) ? 'r' : '-';
1000      $other .= ($mode & 00002) ? 'w' : '-';
1001      if ($mode & 0x200) {
1002          $other .= ($mode & 00001) ? 't' : 'T';
1003      } else {
1004          $other .= ($mode & 00001) ? 'x' : '-';
1005      }
1006  
1007      return $type . $owner . $group . $other;
1008  
1009  }
1010  
1011  function is_script ($filename) {
1012      return ereg('\.php$|\.php3$|\.php4$|\.php5$', $filename);
1013  }
1014  
1015  function getmimetype ($filename) {
1016      static $mimes = array(
1017          '\.jpg$|\.jpeg$'  => 'image/jpeg',
1018          '\.gif$'          => 'image/gif',
1019          '\.png$'          => 'image/png',
1020          '\.html$|\.html$' => 'text/html',
1021          '\.txt$|\.asc$'   => 'text/plain',
1022          '\.xml$|\.xsl$'   => 'application/xml',
1023          '\.pdf$'          => 'application/pdf'
1024      );
1025  
1026      foreach ($mimes as $regex => $mime) {
1027          if (eregi($regex, $filename)) return $mime;
1028      }
1029  
1030      // return 'application/octet-stream';
1031      return 'text/plain';
1032  
1033  }
1034  
1035  function del ($file) {
1036      global $delim;
1037  
1038      if (!file_exists($file)) return false;
1039  
1040      if (@is_dir($file) && !@is_link($file)) {
1041  
1042          $success = false;
1043  
1044          if (@rmdir($file)) {
1045  
1046              $success = true;
1047  
1048          } elseif ($dir = @opendir($file)) {
1049  
1050              $success = true;
1051  
1052              while (($f = readdir($dir)) !== false) {
1053                  if ($f != '.' && $f != '..' && !del($file . $delim . $f)) {
1054                      $success = false;
1055                  }
1056              }
1057              closedir($dir);
1058  
1059              if ($success) $success = @rmdir($file);
1060  
1061          }
1062  
1063          return $success;
1064  
1065      }
1066  
1067      return @unlink($file);
1068  
1069  }
1070  
1071  function addslash ($directory) {
1072      global $delim;
1073  
1074      if (substr($directory, -1, 1) != $delim) {
1075          return $directory . $delim;
1076      } else {
1077          return $directory;
1078      }
1079  
1080  }
1081  
1082  function relative2absolute ($string, $directory) {
1083  
1084      if (path_is_relative($string)) {
1085          return simplify_path(addslash($directory) . $string);
1086      } else {
1087          return simplify_path($string);
1088      }
1089  
1090  }
1091  
1092  function path_is_relative ($path) {
1093      global $win;
1094  
1095      if ($win) {
1096          return (substr($path, 1, 1) != ':');
1097      } else {
1098          return (substr($path, 0, 1) != '/');
1099      }
1100  
1101  }
1102  
1103  function absolute2relative ($directory, $target) {
1104      global $delim;
1105  
1106      $path = '';
1107      while ($directory != $target) {
1108          if ($directory == substr($target, 0, strlen($directory))) {
1109              $path .= substr($target, strlen($directory));
1110              break;
1111          } else {
1112              $path .= '..' . $delim;
1113              $directory = substr($directory, 0, strrpos(substr($directory, 0, -1), $delim) + 1);
1114          }
1115      }
1116      if ($path == '') $path = '.';
1117  
1118      return $path;
1119  
1120  }
1121  
1122  function simplify_path ($path) {
1123      global $delim;
1124  
1125      if (@file_exists($path) && function_exists('realpath') && @realpath($path) != '') {
1126          $path = realpath($path);
1127          if (@is_dir($path)) {
1128              return addslash($path);
1129          } else {
1130              return $path;
1131          }
1132      }
1133  
1134      $pattern  = $delim . '.' . $delim;
1135  
1136      if (@is_dir($path)) {
1137          $path = addslash($path);
1138      }
1139  
1140      while (strpos($path, $pattern) !== false) {
1141          $path = str_replace($pattern, $delim, $path);
1142      }
1143  
1144      $e = addslashes($delim);
1145      $regex = $e . '((\.[^\.' . $e . '][^' . $e . ']*)|(\.\.[^' . $e . ']+)|([^\.][^' . $e . ']*))' . $e . '\.\.' . $e;
1146  
1147      while (ereg($regex, $path)) {
1148          $path = ereg_replace($regex, $delim, $path);
1149      }
1150      
1151      return $path;
1152  
1153  }
1154  
1155  function human_filesize ($filesize) {
1156  
1157      $suffices = 'kMGTPE';
1158  
1159      $n = 0;
1160      while ($filesize >= 1000) {
1161          $filesize /= 1024;
1162          $n++;
1163      }
1164  
1165      $filesize = round($filesize, 3 - strpos($filesize, '.'));
1166  
1167      if (strpos($filesize, '.') !== false) {
1168          while (in_array(substr($filesize, -1, 1), array('0', '.'))) {
1169              $filesize = substr($filesize, 0, strlen($filesize) - 1);
1170          }
1171      }
1172  
1173      $suffix = (($n == 0) ? '' : substr($suffices, $n - 1, 1));
1174  
1175      return $filesize . " {$suffix}B";
1176  
1177  }
1178  
1179  function strip (&$str) {
1180      $str = stripslashes($str);
1181  }
1182  
1183  /* ------------------------------------------------------------------------- */
1184  
1185  function listing_page ($message = null) {
1186      global $self, $directory, $sort, $reverse;
1187  
1188      html_header();
1189  
1190      $list = getlist($directory);
1191  
1192      if (array_key_exists('sort', $_GET)) $sort = $_GET['sort']; else $sort = 'filename';
1193      if (array_key_exists('reverse', $_GET) && $_GET['reverse'] == 'true') $reverse = true; else $reverse = false;
1194  
1195      $list = sortlist($list, $sort, $reverse);
1196  
1197      echo '<h1 style="margin-bottom: 0">Web File Browser (webadmin.php)</h1>
1198  
1199  <form enctype="multipart/form-data" action="' . $self . '" method="post">
1200  
1201  <table id="main">
1202  ';
1203  
1204      directory_choice();
1205  
1206      if (!empty($message)) {
1207          spacer();
1208          echo $message;
1209      }
1210  
1211      if (@is_writable($directory)) {
1212          upload_box();
1213          create_box();
1214      } else {
1215          spacer();
1216      }
1217  
1218      if ($list) {
1219          listing($list);
1220      } else {
1221          echo error('not_readable', $directory);
1222      }
1223  
1224      echo '</table>
1225  
1226  </form>
1227  
1228  ';
1229  
1230      html_footer();
1231  
1232  }
1233  
1234  function listing ($list) {
1235      global $directory, $homedir, $sort, $reverse, $win, $cols, $date_format, $self;
1236  
1237      echo '<tr class="listing">
1238      <th style="text-align: center; vertical-align: middle"><img src="' . $self . '&image=smiley" alt="smiley" /></th>
1239  ';
1240  
1241      column_title('filename', $sort, $reverse);
1242      column_title('size', $sort, $reverse);
1243  
1244      column_title('Created', $sort, $reverse);
1245      column_title('Modified', $sort, $reverse);
1246  
1247      column_title('permission', $sort, $reverse);
1248      column_title('owner', $sort, $reverse);
1249      column_title('group', $sort, $reverse);
1250  
1251      echo '    <th class="functions">' . word('functions') . '</th>
1252  </tr>
1253  ';
1254  
1255      echo '
1256      <tr class="listing"><td class="checkbox"><input type="checkbox" onclick="select_all(this)" /></td></tr>
1257      ';
1258      for ($i = 0; $i < sizeof($list); $i++) {
1259          $file = $list[$i];
1260  
1261          $timestamps  = 'mtime: ' . date($date_format, $file['mtime']) . ', ';
1262          $timestamps .= 'atime: ' . date($date_format, $file['atime']) . ', ';
1263          $timestamps .= 'ctime: ' . date($date_format, $file['ctime']);
1264  
1265          echo '<tr class="listing">
1266      <td class="checkbox"><input type="checkbox" name="checked' . $i . '" value="true" onfocus="activate(\'other\')" /></td>
1267      <td class="filename" title="' . html($timestamps) . '">';
1268  
1269          if ($file['is_link']) {
1270  
1271              echo '<img src="' . $self . '&image=link" alt="link" /> ';
1272              echo html($file['filename']) . ' &rarr; ';
1273  
1274              $real_file = relative2absolute($file['target'], $directory);
1275  
1276              if (@is_readable($real_file)) {
1277                  if (@is_dir($real_file)) {
1278                      echo '[ <a href="' . $self . '&dir=' . urlencode($real_file) . '">' . html($file['target']) . '</a> ]';
1279                  } else {
1280                      echo '<a href="' . $self . '&action=view&amp;file=' . urlencode($real_file) . '">' . html($file['target']) . '</a>';
1281                  }
1282              } else {
1283                  echo html($file['target']);
1284              }
1285  
1286          } elseif ($file['is_dir']) {
1287  
1288              echo '<img src="' . $self . '&image=folder" alt="folder" /> [ ';
1289              if ($win || $file['is_executable']) {
1290                  echo '<a href="' . $self . '&dir=' . urlencode($file['path']) . '">' . html($file['filename']) . '</a>';
1291              } else {
1292                  echo html($file['filename']);
1293              }
1294              echo ' ]';
1295  
1296          } else {
1297  
1298              if (substr($file['filename'], 0, 1) == '.') {
1299                  echo '<img src="' . $self . '&image=hidden_file" alt="hidden file" /> ';
1300              } else {
1301                  echo '<img src="' . $self . '&image=file" alt="file" /> ';
1302              }
1303  
1304              if ($file['is_file'] && $file['is_readable']) {
1305                 echo '<a href="' . $self . '&action=view&amp;file=' . urlencode($file['path']) . '">' . html($file['filename']) . '</a>';
1306              } else {
1307                  echo html($file['filename']);
1308              }
1309  
1310          }
1311  
1312          if ($file['size'] >= 1000) {
1313              $human = ' title="' . human_filesize($file['size']) . '"';
1314          } else {
1315              $human = '';
1316          }
1317  
1318          echo "</td>\n";
1319  
1320          echo "\t<td class=\"size\"$human>{$file['size']} B</td>\n";
1321          echo "\t<td class=\"ctime\"$human>".date('Y-m-d H:i:s',$file['ctime'])."</td>\n";
1322          echo "\t<td class=\"mtime\"$human>".date('Y-m-d H:i:s',$file['mtime'])."</td>\n";
1323  
1324              echo "\t<td class=\"permission\" title=\"" . decoct($file['permission']) . '">';
1325  
1326              $l = !$file['is_link'] && (!function_exists('posix_getuid') || $file['owner'] == posix_getuid());
1327              if ($l) echo '<a href="' . $self . '&action=permission&amp;file=' . urlencode($file['path']) . '&amp;dir=' . urlencode($directory) . '">';
1328              echo html(permission_octal2string($file['permission']));
1329              if ($l) echo '</a>';
1330  
1331              echo "</td>\n";
1332  
1333              if (array_key_exists('owner_name', $file)) {
1334                  echo "\t<td class=\"owner\" title=\"uid: {$file['owner']}\">{$file['owner_name']}</td>\n";
1335              } else {
1336                  echo "\t<td class=\"owner\">{$file['owner']}</td>\n";
1337              }
1338  
1339              if (array_key_exists('group_name', $file)) {
1340                  echo "\t<td class=\"group\" title=\"gid: {$file['group']}\">{$file['group_name']}</td>\n";
1341              } else {
1342                  echo "\t<td class=\"group\">{$file['group']}</td>\n";
1343              }
1344  
1345          echo '    <td class="functions">
1346          <input type="hidden" name="file' . $i . '" value="' . html($file['path']) . '" />
1347  ';
1348  
1349          $actions = array();
1350          if (function_exists('symlink')) {
1351              $actions[] = 'create_symlink';
1352          }
1353          if (@is_writable(dirname($file['path']))) {
1354              $actions[] = 'delete';
1355              $actions[] = 'rename';
1356              $actions[] = 'move';
1357          }
1358          if ($file['is_file'] && $file['is_readable']) {
1359              $actions[] = 'copy';
1360              $actions[] = 'download';
1361              if ($file['is_writable']) $actions[] = 'edit';
1362          }
1363          if (!$win && function_exists('exec') && $file['is_file'] && $file['is_executable'] && file_exists('/bin/sh')) {
1364              $actions[] = 'execute';
1365          }
1366  
1367          if (sizeof($actions) > 0) {
1368  
1369              echo '        <select class="small" name="action' . $i . '" size="1">
1370          <option value="">' . str_repeat('&nbsp;', 30) . '</option>
1371  ';
1372  
1373              foreach ($actions as $action) {
1374                  echo "\t\t<option value=\"$action\">" . word($action) . "</option>\n";
1375              }
1376  
1377              echo '        </select>
1378          <input class="small" type="submit" name="submit' . $i . '" value=" &gt; " onfocus="activate(\'other\')" />
1379  ';
1380  
1381          }
1382  
1383          echo '    </td>
1384  </tr>
1385  ';
1386  
1387      }
1388  
1389      echo '<tr class="listing_footer">
1390      <td style="text-align: right; vertical-align: top"><img src="' . $self . '&image=arrow" alt="&gt;" /></td>
1391      <td colspan="' . ($cols - 1) . '">
1392          <input type="hidden" name="num" value="' . sizeof($list) . '" />
1393          <input type="hidden" name="focus" value="" />
1394          <input type="hidden" name="olddir" value="' . html($directory) . '" />
1395  ';
1396  
1397      $actions = array();
1398      if (@is_writable(dirname($file['path']))) {
1399          $actions[] = 'delete';
1400          $actions[] = 'move';
1401      }
1402      $actions[] = 'copy';
1403  
1404      echo '        <select class="small" name="action_all" size="1">
1405          <option value="">' . str_repeat('&nbsp;', 30) . '</option>
1406  ';
1407  
1408      foreach ($actions as $action) {
1409          echo "\t\t<option value=\"$action\">" . word($action) . "</option>\n";
1410      }
1411  
1412      echo '        </select>
1413          <input class="small" type="submit" name="submit_all" value=" &gt; " onfocus="activate(\'other\')" />
1414      </td>
1415  </tr>
1416  ';
1417  
1418  }
1419  
1420  function column_title ($column, $sort, $reverse) {
1421      global $self, $directory;
1422  
1423      $d = 'dir=' . urlencode($directory) . '&amp;';
1424  
1425      if ($sort == $column) {
1426          if (!$reverse) {
1427              $r = '&amp;reverse=true';
1428              $arr = ' &and;';
1429          } else {
1430              $arr = ' &or;';
1431          }
1432      } else {
1433          $r = '';
1434      }
1435      echo "\t<th class=\"$column\"><a href=\"$self&{$d}sort=$column$r\">" . word($column) . "</a>$arr</th>\n";
1436  
1437  }
1438  
1439  function directory_choice () {
1440      global $directory, $homedir, $cols, $self;
1441  
1442      echo '<tr>
1443      <td colspan="' . $cols . '" id="directory">
1444          <a href="' . $self . '&dir=' . urlencode($homedir) . '">' . word('directory') . '</a>:
1445          <input type="text" name="dir" size="' . textfieldsize($directory) . '" value="' . html($directory) . '" onfocus="activate(\'directory\')" />
1446          <input type="submit" name="changedir" value="' . word('change') . '" onfocus="activate(\'directory\')" />
1447      </td>
1448  </tr>
1449  ';
1450  
1451  }
1452  
1453  function upload_box () {
1454      global $cols;
1455  
1456      echo '<tr>
1457      <td colspan="' . $cols . '" id="upload">
1458          ' . word('file') . ':
1459          <input type="file" name="upload" onfocus="activate(\'other\')" />
1460          <input type="submit" name="submit_upload" value="' . word('upload') . '" onfocus="activate(\'other\')" />
1461      </td>
1462  </tr>
1463  ';
1464  
1465  }
1466  
1467  function create_box () {
1468      global $cols;
1469  
1470      echo '<tr>
1471      <td colspan="' . $cols . '" id="create">
1472          <select name="create_type" size="1" onfocus="activate(\'create\')">
1473          <option value="file">' . word('file') . '</option>
1474          <option value="directory">' . word('directory') . '</option>
1475          </select>
1476          <input type="text" name="create_name" onfocus="activate(\'create\')" />
1477          <input type="submit" name="submit_create" value="' . word('create') . '" onfocus="activate(\'create\')" />
1478      </td>
1479  </tr>
1480  ';
1481  
1482  }
1483  
1484  function edit ($file) {
1485      global $self, $directory, $editcols, $editrows, $apache, $htpasswd, $htaccess;
1486  
1487      html_header();
1488  
1489      echo '<h2 style="margin-bottom: 3pt">' . html($file) . '</h2>
1490  
1491  <form action="' . $self . '" method="post">
1492  
1493  <table id="dialog" class="dialog" style="width:90%;">
1494  <tr>
1495  <td class="dialog" style="height:100%;">
1496  
1497      <textarea name="content" cols="' . $editcols . '" rows="' . $editrows . '" WRAP="off" style="width:100%; height:100%;">';
1498  
1499      if (array_key_exists('content', $_POST)) {
1500          echo $_POST['content'];
1501      } else {
1502          echo html(file_get_contents($file));
1503      }
1504  
1505      if (!empty($_POST['user'])) {
1506          echo "\n" . $_POST['user'] . ':' . crypt($_POST['password']);
1507      }
1508      if (!empty($_POST['basic_auth'])) {
1509          if ($win) {
1510              $authfile = str_replace('\\', '/', $directory) . $htpasswd;
1511          } else {
1512              $authfile = $directory . $htpasswd;
1513          }
1514          echo "\nAuthType Basic\nAuthName &quot;Restricted Directory&quot;\n";
1515          echo 'AuthUserFile &quot;' . html($authfile) . "&quot;\n";
1516          echo 'Require valid-user';
1517      }
1518  
1519      echo '</textarea>
1520  
1521      <hr />
1522  ';
1523  
1524      if ($apache && basename($file) == $htpasswd) {
1525          echo '
1526      ' . word('user') . ': <input type="text" name="user" />
1527      ' . word('password') . ': <input type="password" name="password" />
1528      <input type="submit" value="' . word('add') . '" />
1529  
1530      <hr />
1531  ';
1532  
1533      }
1534  
1535      if ($apache && basename($file) == $htaccess) {
1536          echo '
1537      <input type="submit" name="basic_auth" value="' . word('add_basic_auth') . '" />
1538  
1539      <hr />
1540  ';
1541  
1542      }
1543  
1544      echo '
1545      <input type="hidden" name="action" value="edit" />
1546      <input type="hidden" name="file" value="' . html($file) . '" />
1547      <input type="hidden" name="dir" value="' . html($directory) . '" />
1548      <input type="reset" value="' . word('reset') . '" id="red_button" />
1549      <input type="submit" name="save" value="' . word('save') . '" id="green_button" style="margin-left: 50px" />
1550  
1551  </td>
1552  </tr>
1553  </table>
1554  
1555  <script>
1556  document.getElementById("dialog").style.height = window.innerHeight-100+"px";
1557  </script>
1558  
1559  <p><a href="' . $self . '&dir=' . urlencode($directory) . '">[ ' . word('back') . ' ]</a></p>
1560  
1561  </form>
1562  
1563  ';
1564  
1565      html_footer();
1566  
1567  }
1568  
1569  function spacer () {
1570      global $cols;
1571  
1572      echo '<tr>
1573      <td colspan="' . $cols . '" style="height: 1em"></td>
1574  </tr>
1575  ';
1576  
1577  }
1578  
1579  function textfieldsize ($content) {
1580  
1581      $size = strlen($content) + 5;
1582      if ($size < 30) $size = 30;
1583  
1584      return $size;
1585  
1586  }
1587  
1588  function request_dump () {
1589  
1590      foreach ($_REQUEST as $key => $value) {
1591          echo "\t<input type=\"hidden\" name=\"" . html($key) . '" value="' . html($value) . "\" />\n";
1592      }
1593  
1594  }
1595  
1596  /* ------------------------------------------------------------------------- */
1597  
1598  function html ($string) {
1599      global $site_charset;
1600      if (!detect_utf($string)) $string = utf8_encode($string);
1601      return htmlspecialchars($string, ENT_COMPAT, $site_charset);
1602  }
1603  
1604  function detect_utf($string) {
1605    return preg_match('%(?:
1606      [\xC2-\xDF][\x80-\xBF]
1607      |\xE0[\xA0-\xBF][\x80-\xBF]
1608      |[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
1609      |\xED[\x80-\x9F][\x80-\xBF]
1610      |\xF0[\x90-\xBF][\x80-\xBF]{2}
1611      |[\xF1-\xF3][\x80-\xBF]{3}
1612      |\xF4[\x80-\x8F][\x80-\xBF]{2}
1613    )+%xs', $string);
1614  }
1615  
1616  function word ($word) {
1617      global $words, $word_charset;
1618      return htmlentities($words[$word] ? $words[$word] : $word, ENT_COMPAT, $word_charset);
1619  }
1620  
1621  function phrase ($phrase, $arguments) {
1622      global $words;
1623      static $search;
1624  
1625      if (!is_array($search)) for ($i = 1; $i <= 8; $i++) $search[] = "%$i";
1626  
1627      for ($i = 0; $i < sizeof($arguments); $i++) {
1628          $arguments[$i] = nl2br(html($arguments[$i]));
1629      }
1630  
1631      $replace = array('{' => '<pre>', '}' =>'</pre>', '[' => '<b>', ']' => '</b>');
1632  
1633      return str_replace($search, $arguments, str_replace(array_keys($replace), $replace, nl2br(html($words[$phrase]))));
1634  
1635  }
1636  
1637  function getwords ($lang) {
1638      global $word_charset, $date_format;
1639  
1640      switch ($lang) {
1641      case 'de':
1642  
1643          $date_format = 'd.m.y H:i:s';
1644          $word_charset = 'utf-8';
1645  
1646          return array(
1647  'directory' => 'Verzeichnis',
1648  'file' => 'Datei',
1649  'filename' => 'Dateiname',
1650  
1651  'size' => 'Größe',
1652  'permission' => 'Rechte',
1653  'owner' => 'Eigner',
1654  'group' => 'Gruppe',
1655  'other' => 'Andere',
1656  'functions' => 'Funktionen',
1657  
1658  'read' => 'lesen',
1659  'write' => 'schreiben',
1660  'execute' => 'ausführen',
1661  
1662  'create_symlink' => 'Symlink erstellen',
1663  'delete' => 'löschen',
1664  'rename' => 'umbenennen',
1665  'move' => 'verschieben',
1666  'copy' => 'kopieren',
1667  'edit' => 'editieren',
1668  'download' => 'herunterladen',
1669  'upload' => 'hochladen',
1670  'create' => 'erstellen',
1671  'change' => 'wechseln',
1672  'save' => 'speichern',
1673  'set' => 'setze',
1674  'reset' => 'zurücksetzen',
1675  'relative' => 'Pfad zum Ziel relativ',
1676  
1677  'yes' => 'Ja',
1678  'no' => 'Nein',
1679  'back' => 'zurück',
1680  'destination' => 'Ziel',
1681  'symlink' => 'Symbolischer Link',
1682  'no_output' => 'keine Ausgabe',
1683  
1684  'user' => 'Benutzername',
1685  'password' => 'Kennwort',
1686  'add' => 'hinzufügen',
1687  'add_basic_auth' => 'HTTP-Basic-Auth hinzufügen',
1688  
1689  'uploaded' => '"[%1]" wurde hochgeladen.',
1690  'not_uploaded' => '"[%1]" konnte nicht hochgeladen werden.',
1691  'already_exists' => '"[%1]" existiert bereits.',
1692  'created' => '"[%1]" wurde erstellt.',
1693  'not_created' => '"[%1]" konnte nicht erstellt werden.',
1694  'really_delete' => 'Sollen folgende Dateien wirklich gelöscht werden?',
1695  'deleted' => "Folgende Dateien wurden gelöscht:\n[%1]",
1696  'not_deleted' => "Folgende Dateien konnten nicht gelöscht werden:\n[%1]",
1697  'rename_file' => 'Benenne Datei um:',
1698  'renamed' => '"[%1]" wurde in "[%2]" umbenannt.',
1699  'not_renamed' => '"[%1] konnte nicht in "[%2]" umbenannt werden.',
1700  'move_files' => 'Verschieben folgende Dateien:',
1701  'moved' => "Folgende Dateien wurden nach \"[%2]\" verschoben:\n[%1]",
1702  'not_moved' => "Folgende Dateien konnten nicht nach \"[%2]\" verschoben werden:\n[%1]",
1703  'copy_files' => 'Kopiere folgende Dateien:',
1704  'copied' => "Folgende Dateien wurden nach \"[%2]\" kopiert:\n[%1]",
1705  'not_copied' => "Folgende Dateien konnten nicht nach \"[%2]\" kopiert werden:\n[%1]",
1706  'not_edited' => '"[%1]" kann nicht editiert werden.',
1707  'executed' => "\"[%1]\" wurde erfolgreich ausgeführt:\n{%2}",
1708  'not_executed' => "\"[%1]\" konnte nicht erfolgreich ausgeführt werden:\n{%2}",
1709  'saved' => '"[%1]" wurde gespeichert.',
1710  'not_saved' => '"[%1]" konnte nicht gespeichert werden.',
1711  'symlinked' => 'Symbolischer Link von "[%2]" nach "[%1]" wurde erstellt.',
1712  'not_symlinked' => 'Symbolischer Link von "[%2]" nach "[%1]" konnte nicht erstellt werden.',
1713  'permission_for' => 'Rechte für "[%1]":',
1714  'permission_set' => 'Die Rechte für "[%1]" wurden auf [%2] gesetzt.',
1715  'permission_not_set' => 'Die Rechte für "[%1]" konnten nicht auf [%2] gesetzt werden.',
1716  'not_readable' => '"[%1]" kann nicht gelesen werden.'
1717          );
1718  
1719      case 'fr':
1720  
1721          $date_format = 'd.m.y H:i:s';
1722          $word_charset = 'utf-8';
1723  
1724          return array(
1725  'directory' => 'Répertoire',
1726  'file' => 'Fichier',
1727  'filename' => 'Nom fichier',
1728  
1729  'size' => 'Taille',
1730  'permission' => 'Droits',
1731  'owner' => 'Propriétaire',
1732  'group' => 'Groupe',
1733  'other' => 'Autres',
1734  'functions' => 'Fonctions',
1735  
1736  'read' => 'Lire',
1737  'write' => 'Ecrire',
1738  'execute' => 'Exécuter',
1739  
1740  'create_symlink' => 'Créer lien symbolique',
1741  'delete' => 'Effacer',
1742  'rename' => 'Renommer',
1743  'move' => 'Déplacer',
1744  'copy' => 'Copier',
1745  'edit' => 'Ouvrir',
1746  'download' => 'Télécharger sur PC',
1747  'upload' => 'Télécharger sur serveur',
1748  'create' => 'Créer',
1749  'change' => 'Changer',
1750  'save' => 'Sauvegarder',
1751  'set' => 'Exécuter',
1752  'reset' => 'Réinitialiser',
1753  'relative' => 'Relatif',
1754  
1755  'yes' => 'Oui',
1756  'no' => 'Non',
1757  'back' => 'Retour',
1758  'destination' => 'Destination',
1759  'symlink' => 'Lien symbollique',
1760  'no_output' => 'Pas de sortie',
1761  
1762  'user' => 'Utilisateur',
1763  'password' => 'Mot de passe',
1764  'add' => 'Ajouter',
1765  'add_basic_auth' => 'add basic-authentification',
1766  
1767  'uploaded' => '"[%1]" a été téléchargé sur le serveur.',
1768  'not_uploaded' => '"[%1]" n a pas été téléchargé sur le serveur.',
1769  'already_exists' => '"[%1]" existe déjà.',
1770  'created' => '"[%1]" a été créé.',
1771  'not_created' => '"[%1]" n a pas pu être créé.',
1772  'really_delete' => 'Effacer le fichier?',
1773  'deleted' => "Ces fichiers ont été détuits:\n[%1]",
1774  'not_deleted' => "Ces fichiers n ont pu être détruits:\n[%1]",
1775  'rename_file' => 'Renomme fichier:',
1776  'renamed' => '"[%1]" a été renommé en "[%2]".',
1777  'not_renamed' => '"[%1] n a pas pu être renommé en "[%2]".',
1778  'move_files' => 'Déplacer ces fichiers:',
1779  'moved' => "Ces fichiers ont été déplacés en \"[%2]\":\n[%1]",
1780  'not_moved' => "Ces fichiers n ont pas pu être déplacés en \"[%2]\":\n[%1]",
1781  'copy_files' => 'Copier ces fichiers:',
1782  'copied' => "Ces fichiers ont été copiés en \"[%2]\":\n[%1]",
1783  'not_copied' => "Ces fichiers n ont pas pu être copiés en \"[%2]\":\n[%1]",
1784  'not_edited' => '"[%1]" ne peut être ouvert.',
1785  'executed' => "\"[%1]\" a été brillamment exécuté :\n{%2}",
1786  'not_executed' => "\"[%1]\" n a pas pu être exécuté:\n{%2}",
1787  'saved' => '"[%1]" a été sauvegardé.',
1788  'not_saved' => '"[%1]" n a pas pu être sauvegardé.',
1789  'symlinked' => 'Un lien symbolique depuis "[%2]" vers "[%1]" a été crée.',
1790  'not_symlinked' => 'Un lien symbolique depuis "[%2]" vers "[%1]" n a pas pu être créé.',
1791  'permission_for' => 'Droits de "[%1]":',
1792  'permission_set' => 'Droits de "[%1]" ont été changés en [%2].',
1793  'permission_not_set' => 'Droits de "[%1]" n ont pas pu être changés en[%2].',
1794  'not_readable' => '"[%1]" ne peut pas être ouvert.'
1795          );
1796  
1797      case 'it':
1798  
1799          $date_format = 'd-m-Y H:i:s';
1800          $word_charset = 'utf-8';
1801  
1802          return array(
1803  'directory' => 'Directory',
1804  'file' => 'File',
1805  'filename' => 'Nome File',
1806  
1807  'size' => 'Dimensioni',
1808  'permission' => 'Permessi',
1809  'owner' => 'Proprietario',
1810  'group' => 'Gruppo',
1811  'other' => 'Altro',
1812  'functions' => 'Funzioni',
1813  
1814  'read' => 'leggi',
1815  'write' => 'scrivi',
1816  'execute' => 'esegui',
1817  
1818  'create_symlink' => 'crea link simbolico',
1819  'delete' => 'cancella',
1820  'rename' => 'rinomina',
1821  'move' => 'sposta',
1822  'copy' => 'copia',
1823  'edit' => 'modifica',
1824  'download' => 'download',
1825  'upload' => 'upload',
1826  'create' => 'crea',
1827  'change' => 'cambia',
1828  'save' => 'salva',
1829  'set' => 'imposta',
1830  'reset' => 'reimposta',
1831  'relative' => 'Percorso relativo per la destinazione',
1832  
1833  'yes' => 'Si',
1834  'no' => 'No',
1835  'back' => 'indietro',
1836  'destination' => 'Destinazione',
1837  'symlink' => 'Link simbolico',
1838  'no_output' => 'no output',
1839  
1840  'user' => 'User',
1841  'password' => 'Password',
1842  'add' => 'aggiungi',
1843  'add_basic_auth' => 'aggiungi autenticazione base',
1844  
1845  'uploaded' => '"[%1]" è stato caricato.',
1846  'not_uploaded' => '"[%1]" non è stato caricato.',
1847  'already_exists' => '"[%1]" esiste già.',
1848  'created' => '"[%1]" è stato creato.',
1849  'not_created' => '"[%1]" non è stato creato.',
1850  'really_delete' => 'Cancello questi file ?',
1851  'deleted' => "Questi file sono stati cancellati:\n[%1]",
1852  'not_deleted' => "Questi file non possono essere cancellati:\n[%1]",
1853  'rename_file' => 'File rinominato:',
1854  'renamed' => '"[%1]" è stato rinominato in "[%2]".',
1855  'not_renamed' => '"[%1] non è stato rinominato in "[%2]".',
1856  'move_files' => 'Sposto questi file:',
1857  'moved' => "Questi file sono stati spostati in \"[%2]\":\n[%1]",
1858  'not_moved' => "Questi file non possono essere spostati in \"[%2]\":\n[%1]",
1859  'copy_files' => 'Copio questi file',
1860  'copied' => "Questi file sono stati copiati in \"[%2]\":\n[%1]",
1861  'not_copied' => "Questi file non possono essere copiati in \"[%2]\":\n[%1]",
1862  'not_edited' => '"[%1]" non può essere modificato.',
1863  'executed' => "\"[%1]\" è stato eseguito con successo:\n{%2}",
1864  'not_executed' => "\"[%1]\" non è stato eseguito con successo\n{%2}",
1865  'saved' => '"[%1]" è stato salvato.',
1866  'not_saved' => '"[%1]" non è stato salvato.',
1867  'symlinked' => 'Il link siambolico da "[%2]" a "[%1]" è stato creato.',
1868  'not_symlinked' => 'Il link siambolico da "[%2]" a "[%1]" non è stato creato.',
1869  'permission_for' => 'Permessi di "[%1]":',
1870  'permission_set' => 'I permessi di "[%1]" sono stati impostati [%2].',
1871  'permission_not_set' => 'I permessi di "[%1]" non sono stati impostati [%2].',
1872  'not_readable' => '"[%1]" non può essere letto.'
1873          );
1874  
1875      case 'nl':
1876  
1877          $date_format = 'n/j/y H:i:s';
1878          $word_charset = 'utf-8';
1879  
1880          return array(
1881  'directory' => 'Directory',
1882  'file' => 'Bestand',
1883  'filename' => 'Bestandsnaam',
1884  
1885  'size' => 'Grootte',
1886  'permission' => 'Bevoegdheid',
1887  'owner' => 'Eigenaar',
1888  'group' => 'Groep',
1889  'other' => 'Anderen',
1890  'functions' => 'Functies',
1891  
1892  'read' => 'lezen',
1893  'write' => 'schrijven',
1894  'execute' => 'uitvoeren',
1895  
1896  'create_symlink' => 'maak symlink',
1897  'delete' => 'verwijderen',
1898  'rename' => 'hernoemen',
1899  'move' => 'verplaatsen',
1900  'copy' => 'kopieren',
1901  'edit' => 'bewerken',
1902  'download' => 'downloaden',
1903  'upload' => 'uploaden',
1904  'create' => 'aanmaken',
1905  'change' => 'veranderen',
1906  'save' => 'opslaan',
1907  'set' => 'instellen',
1908  'reset' => 'resetten',
1909  'relative' => 'Relatief pat naar doel',
1910  
1911  'yes' => 'Ja',
1912  'no' => 'Nee',
1913  'back' => 'terug',
1914  'destination' => 'Bestemming',
1915  'symlink' => 'Symlink',
1916  'no_output' => 'geen output',
1917  
1918  'user' => 'Gebruiker',
1919  'password' => 'Wachtwoord',
1920  'add' => 'toevoegen',
1921  'add_basic_auth' => 'add basic-authentification',
1922  
1923  'uploaded' => '"[%1]" is verstuurd.',
1924  'not_uploaded' => '"[%1]" kan niet worden verstuurd.',
1925  'already_exists' => '"[%1]" bestaat al.',
1926  'created' => '"[%1]" is aangemaakt.',
1927  'not_created' => '"[%1]" kan niet worden aangemaakt.',
1928  'really_delete' => 'Deze bestanden verwijderen?',
1929  'deleted' => "Deze bestanden zijn verwijderd:\n[%1]",
1930  'not_deleted' => "Deze bestanden konden niet worden verwijderd:\n[%1]",
1931  'rename_file' => 'Bestandsnaam veranderen:',
1932  'renamed' => '"[%1]" heet nu "[%2]".',
1933  'not_renamed' => '"[%1] kon niet worden veranderd in "[%2]".',
1934  'move_files' => 'Verplaats deze bestanden:',
1935  'moved' => "Deze bestanden zijn verplaatst naar \"[%2]\":\n[%1]",
1936  'not_moved' => "Kan deze bestanden niet verplaatsen naar \"[%2]\":\n[%1]",
1937  'copy_files' => 'Kopieer deze bestanden:',
1938  'copied' => "Deze bestanden zijn gekopieerd naar \"[%2]\":\n[%1]",
1939  'not_copied' => "Deze bestanden kunnen niet worden gekopieerd naar \"[%2]\":\n[%1]",
1940  'not_edited' => '"[%1]" kan niet worden bewerkt.',
1941  'executed' => "\"[%1]\" is met succes uitgevoerd:\n{%2}",
1942  'not_executed' => "\"[%1]\" is niet goed uitgevoerd:\n{%2}",
1943  'saved' => '"[%1]" is opgeslagen.',
1944  'not_saved' => '"[%1]" is niet opgeslagen.',
1945  'symlinked' => 'Symlink van "[%2]" naar "[%1]" is aangemaakt.',
1946  'not_symlinked' => 'Symlink van "[%2]" naar "[%1]" is niet aangemaakt.',
1947  'permission_for' => 'Bevoegdheid voor "[%1]":',
1948  'permission_set' => 'Bevoegdheid van "[%1]" is ingesteld op [%2].',
1949  'permission_not_set' => 'Bevoegdheid van "[%1]" is niet ingesteld op [%2].',
1950  'not_readable' => '"[%1]" kan niet worden gelezen.'
1951          );
1952  
1953      case 'se':
1954  
1955          $date_format = 'n/j/y H:i:s';
1956          $word_charset = 'utf-8';
1957   
1958          return array(
1959  'directory' => 'Mapp',
1960  'file' => 'Fil',
1961  'filename' => 'Filnamn',
1962   
1963  'size' => 'Storlek',
1964  'permission' => 'Säkerhetsnivå',
1965  'owner' => 'Ägare',
1966  'group' => 'Grupp',
1967  'other' => 'Andra',
1968  'functions' => 'Funktioner',
1969   
1970  'read' => 'Läs',
1971  'write' => 'Skriv',
1972  'execute' => 'Utför',
1973   
1974  'create_symlink' => 'Skapa symlink',
1975  'delete' => 'Radera',
1976  'rename' => 'Byt namn',
1977  'move' => 'Flytta',
1978  'copy' => 'Kopiera',
1979  'edit' => 'Ändra',
1980  'download' => 'Ladda ner',
1981  'upload' => 'Ladda upp',
1982  'create' => 'Skapa',
1983  'change' => 'Ändra',
1984  'save' => 'Spara',
1985  'set' => 'Markera',
1986  'reset' => 'Töm',
1987  'relative' => 'Relative path to target',
1988   
1989  'yes' => 'Ja',
1990  'no' => 'Nej',
1991  'back' => 'Tillbaks',
1992  'destination' => 'Destination',
1993  'symlink' => 'Symlink',
1994  'no_output' => 'no output',
1995   
1996  'user' => 'Användare',
1997  'password' => 'Lösenord',
1998  'add' => 'Lägg till',
1999  'add_basic_auth' => 'add basic-authentification',
2000   
2001  'uploaded' => '"[%1]" har laddats upp.',
2002  'not_uploaded' => '"[%1]" kunde inte laddas upp.',
2003  'already_exists' => '"[%1]" finns redan.',
2004  'created' => '"[%1]" har skapats.',
2005  'not_created' => '"[%1]" kunde inte skapas.',
2006  'really_delete' => 'Radera dessa filer?',
2007  'deleted' => "De här filerna har raderats:\n[%1]",
2008  'not_deleted' => "Dessa filer kunde inte raderas:\n[%1]",
2009  'rename_file' => 'Byt namn på fil:',
2010  'renamed' => '"[%1]" har bytt namn till "[%2]".',
2011  'not_renamed' => '"[%1] kunde inte döpas om till "[%2]".',
2012  'move_files' => 'Flytta dessa filer:',
2013  'moved' => "Dessa filer har flyttats till \"[%2]\":\n[%1]",
2014  'not_moved' => "Dessa filer kunde inte flyttas till \"[%2]\":\n[%1]",
2015  'copy_files' => 'Kopiera dessa filer:',
2016  'copied' => "Dessa filer har kopierats till \"[%2]\":\n[%1]",
2017  'not_copied' => "Dessa filer kunde inte kopieras till \"[%2]\":\n[%1]",
2018  'not_edited' => '"[%1]" kan inte ändras.',
2019  'executed' => "\"[%1]\" har utförts:\n{%2}",
2020  'not_executed' => "\"[%1]\" kunde inte utföras:\n{%2}",
2021  'saved' => '"[%1]" har sparats.',
2022  'not_saved' => '"[%1]" kunde inte sparas.',
2023  'symlinked' => 'Symlink från "[%2]" till "[%1]" har skapats.',
2024  'not_symlinked' => 'Symlink från "[%2]" till "[%1]" kunde inte skapas.',
2025  'permission_for' => 'Rättigheter för "[%1]":',
2026  'permission_set' => 'Rättigheter för "[%1]" ändrades till [%2].',
2027  'permission_not_set' => 'Permission of "[%1]" could not be set to [%2].',
2028  'not_readable' => '"[%1]" kan inte läsas.'
2029          );
2030  
2031      case 'sp':
2032  
2033          $date_format = 'j/n/y H:i:s';
2034          $word_charset = 'utf-8';
2035  
2036          return array(
2037  'directory' => 'Directorio',
2038  'file' => 'Archivo',
2039  'filename' => 'Nombre Archivo',
2040  
2041  'size' => 'Tamaño',
2042  'permission' => 'Permisos',
2043  'owner' => 'Propietario',
2044  'group' => 'Grupo',
2045  'other' => 'Otros',
2046  'functions' => 'Funciones',
2047  
2048  'read' => 'lectura',
2049  'write' => 'escritura',
2050  'execute' => 'ejecución',
2051  
2052  'create_symlink' => 'crear enlace',
2053  'delete' => 'borrar',
2054  'rename' => 'renombrar',
2055  'move' => 'mover',
2056  'copy' => 'copiar',
2057  'edit' => 'editar',
2058  'download' => 'bajar',
2059  'upload' => 'subir',
2060  'create' => 'crear',
2061  'change' => 'cambiar',
2062  'save' => 'salvar',
2063  'set' => 'setear',
2064  'reset' => 'resetear',
2065  'relative' => 'Path relativo',
2066  
2067  'yes' => 'Si',
2068  'no' => 'No',
2069  'back' => 'atrás',
2070  'destination' => 'Destino',
2071  'symlink' => 'Enlace',
2072  'no_output' => 'sin salida',
2073  
2074  'user' => 'Usuario',
2075  'password' => 'Clave',
2076  'add' => 'agregar',
2077  'add_basic_auth' => 'agregar autentificación básica',
2078  
2079  'uploaded' => '"[%1]" ha sido subido.',
2080  'not_uploaded' => '"[%1]" no pudo ser subido.',
2081  'already_exists' => '"[%1]" ya existe.',
2082  'created' => '"[%1]" ha sido creado.',
2083  'not_created' => '"[%1]" no pudo ser creado.',
2084  'really_delete' => '¿Borra estos archivos?',
2085  'deleted' => "Estos archivos han sido borrados:\n[%1]",
2086  'not_deleted' => "Estos archivos no pudieron ser borrados:\n[%1]",
2087  'rename_file' => 'Renombra archivo:',
2088  'renamed' => '"[%1]" ha sido renombrado a "[%2]".',
2089  'not_renamed' => '"[%1] no pudo ser renombrado a "[%2]".',
2090  'move_files' => 'Mover estos archivos:',
2091  'moved' => "Estos archivos han sido movidos a \"[%2]\":\n[%1]",
2092  'not_moved' => "Estos archivos no pudieron ser movidos a \"[%2]\":\n[%1]",
2093  'copy_files' => 'Copiar estos archivos:',
2094  'copied' => "Estos archivos han sido copiados a  \"[%2]\":\n[%1]",
2095  'not_copied' => "Estos archivos no pudieron ser copiados \"[%2]\":\n[%1]",
2096  'not_edited' => '"[%1]" no pudo ser editado.',
2097  'executed' => "\"[%1]\" ha sido ejecutado correctamente:\n{%2}",
2098  'not_executed' => "\"[%1]\" no pudo ser ejecutado correctamente:\n{%2}",
2099  'saved' => '"[%1]" ha sido salvado.',
2100  'not_saved' => '"[%1]" no pudo ser salvado.',
2101  'symlinked' => 'Enlace desde "[%2]" a "[%1]" ha sido creado.',
2102  'not_symlinked' => 'Enlace desde "[%2]" a "[%1]" no pudo ser creado.',
2103  'permission_for' => 'Permisos de "[%1]":',
2104  'permission_set' => 'Permisos de "[%1]" fueron seteados a [%2].',
2105  'permission_not_set' => 'Permisos de "[%1]" no pudo ser seteado a [%2].',
2106  'not_readable' => '"[%1]" no pudo ser leído.'
2107          );
2108  
2109      case 'dk':
2110  
2111          $date_format = 'n/j/y H:i:s';
2112          $word_charset = 'utf-8';
2113  
2114          return array(
2115  'directory' => 'Mappe',
2116  'file' => 'Fil',
2117  'filename' => 'Filnavn',
2118  
2119  'size' => 'Størrelse',
2120  'permission' => 'Rettighed',
2121  'owner' => 'Ejer',
2122  'group' => 'Gruppe',
2123  'other' => 'Andre',
2124  'functions' => 'Funktioner',
2125  
2126  'read' => 'læs',
2127  'write' => 'skriv',
2128  'execute' => 'kør',
2129  
2130  'create_symlink' => 'opret symbolsk link',
2131  'delete' => 'slet',
2132  'rename' => 'omdøb',
2133  'move' => 'flyt',
2134  'copy' => 'kopier',
2135  'edit' => 'rediger',
2136  'download' => 'download',
2137  'upload' => 'upload',
2138  'create' => 'opret',
2139  'change' => 'skift',
2140  'save' => 'gem',
2141  'set' => 'sæt',
2142  'reset' => 'nulstil',
2143  'relative' => 'Relativ sti til valg',
2144  
2145  'yes' => 'Ja',
2146  'no' => 'Nej',
2147  'back' => 'tilbage',
2148  'destination' => 'Distination',
2149  'symlink' => 'Symbolsk link',
2150  'no_output' => 'ingen resultat',
2151  
2152  'user' => 'Bruger',
2153  'password' => 'Kodeord',
2154  'add' => 'tilføj',
2155  'add_basic_auth' => 'tilføj grundliggende rettigheder',
2156  
2157  'uploaded' => '"[%1]" er blevet uploaded.',
2158  'not_uploaded' => '"[%1]" kunnu ikke uploades.',
2159  'already_exists' => '"[%1]" findes allerede.',
2160  'created' => '"[%1]" er blevet oprettet.',
2161  'not_created' => '"[%1]" kunne ikke oprettes.',
2162  'really_delete' => 'Slet disse filer?',
2163  'deleted' => "Disse filer er blevet slettet:\n[%1]",
2164  'not_deleted' => "Disse filer kunne ikke slettes:\n[%1]",
2165  'rename_file' => 'Omdød fil:',
2166  'renamed' => '"[%1]" er blevet omdøbt til "[%2]".',
2167  'not_renamed' => '"[%1] kunne ikke omdøbes til "[%2]".',
2168  'move_files' => 'Flyt disse filer:',
2169  'moved' => "Disse filer er blevet flyttet til \"[%2]\":\n[%1]",
2170  'not_moved' => "Disse filer kunne ikke flyttes til \"[%2]\":\n[%1]",
2171  'copy_files' => 'Kopier disse filer:',
2172  'copied' => "Disse filer er kopieret til \"[%2]\":\n[%1]",
2173  'not_copied' => "Disse filer kunne ikke kopieres til \"[%2]\":\n[%1]",
2174  'not_edited' => '"[%1]" kan ikke redigeres.',
2175  'executed' => "\"[%1]\" er blevet kørt korrekt:\n{%2}",
2176  'not_executed' => "\"[%1]\" kan ikke køres korrekt:\n{%2}",
2177  'saved' => '"[%1]" er blevet gemt.',
2178  'not_saved' => '"[%1]" kunne ikke gemmes.',
2179  'symlinked' => 'Symbolsk link fra "[%2]" til "[%1]" er blevet oprettet.',
2180  'not_symlinked' => 'Symbolsk link fra "[%2]" til "[%1]" kunne ikke oprettes.',
2181  'permission_for' => 'Rettigheder for "[%1]":',
2182  'permission_set' => 'Rettigheder for "[%1]" blev sat til [%2].',
2183  'permission_not_set' => 'Rettigheder for "[%1]" kunne ikke sættes til [%2].',
2184  'not_readable' => '"[%1]" Kan ikke læses.'
2185          );
2186  
2187      case 'tr':
2188  
2189          $date_format = 'n/j/y H:i:s';
2190          $word_charset = 'utf-8';
2191  
2192          return array(
2193  'directory' => 'Klasör',
2194  'file' => 'Dosya',
2195  'filename' => 'dosya adi',
2196  
2197  'size' => 'boyutu',
2198  'permission' => 'Izin',
2199  'owner' => 'sahib',
2200  'group' => 'Grup',
2201  'other' => 'Digerleri',
2202  'functions' => 'Fonksiyonlar',
2203  
2204  'read' => 'oku',
2205  'write' => 'yaz',
2206  'execute' => 'çalistir',
2207  
2208  'create_symlink' => 'yarat symlink',
2209  'delete' => 'sil',
2210  'rename' => 'ad degistir',
2211  'move' => 'tasi',
2212  'copy' => 'kopyala',
2213  'edit' => 'düzenle',
2214  'download' => 'indir',
2215  'upload' => 'yükle',
2216  'create' => 'create',
2217  'change' => 'degistir',
2218  'save' => 'kaydet',
2219  'set' => 'ayar',
2220  'reset' => 'sifirla',
2221  'relative' => 'Hedef yola göre',
2222  
2223  'yes' => 'Evet',
2224  'no' => 'Hayir',
2225  'back' => 'Geri',
2226  'destination' => 'Hedef',
2227  'symlink' => 'Kýsa yol',
2228  'no_output' => 'çikti yok',
2229  
2230  'user' => 'Kullanici',
2231  'password' => 'Sifre',
2232  'add' => 'ekle',
2233  'add_basic_auth' => 'ekle basit-authentification',
2234  
2235  'uploaded' => '"[%1]" yüklendi.',
2236  'not_uploaded' => '"[%1]" yüklenemedi.',
2237  'already_exists' => '"[%1]" kullanilmakta.',
2238  'created' => '"[%1]" olusturuldu.',
2239  'not_created' => '"[%1]" olusturulamadi.',
2240  'really_delete' => 'Bu dosyalari silmek istediginizden eminmisiniz?',
2241  'deleted' => "Bu dosyalar silindi:\n[%1]",
2242  'not_deleted' => "Bu dosyalar silinemedi:\n[%1]",
2243  'rename_file' => 'Adi degisen dosya:',
2244  'renamed' => '"[%1]" adili dosyanin yeni adi "[%2]".',
2245  'not_renamed' => '"[%1] adi degistirilemedi "[%2]" ile.',
2246  'move_files' => 'Tasinan dosyalar:',
2247  'moved' => "Bu dosyalari tasidiginiz yer \"[%2]\":\n[%1]",
2248  'not_moved' => "Bu dosyalari tasiyamadiginiz yer \"[%2]\":\n[%1]",
2249  'copy_files' => 'Kopyalanan dosyalar:',
2250  'copied' => "Bu dosyalar kopyalandi \"[%2]\":\n[%1]",
2251  'not_copied' => "Bu dosyalar kopyalanamiyor \"[%2]\":\n[%1]",
2252  'not_edited' => '"[%1]" düzenlenemiyor.',
2253  'executed' => "\"[%1]\" basariyla çalistirildi:\n{%2}",
2254  'not_executed' => "\"[%1]\" çalistirilamadi:\n{%2}",
2255  'saved' => '"[%1]" kaydedildi.',
2256  'not_saved' => '"[%1]" kaydedilemedi.',
2257  'symlinked' => '"[%2]" den "[%1]" e kýsayol oluþturuldu.',
2258  'not_symlinked' => '"[%2]"den "[%1]" e kýsayol oluþturulamadý.',
2259  'permission_for' => 'Izinler "[%1]":',
2260  'permission_set' => 'Izinler "[%1]" degistirildi [%2].',
2261  'permission_not_set' => 'Izinler "[%1]" degistirilemedi [%2].',
2262  'not_readable' => '"[%1]" okunamiyor.'
2263          );
2264  
2265      case 'en':
2266      default:
2267  
2268          $date_format = 'n/j/y H:i:s';
2269          $word_charset = 'utf-8';
2270  
2271          return array(
2272  'directory' => 'Directory',
2273  'file' => 'File',
2274  'filename' => 'Filename',
2275  
2276  'size' => 'Size',
2277  'permission' => 'Permission',
2278  'owner' => 'Owner',
2279  'group' => 'Group',
2280  'other' => 'Others',
2281  'functions' => 'Functions',
2282  
2283  'read' => 'read',
2284  'write' => 'write',
2285  'execute' => 'execute',
2286  
2287  'create_symlink' => 'create symlink',
2288  'delete' => 'delete',
2289  'rename' => 'rename',
2290  'move' => 'move',
2291  'copy' => 'copy',
2292  'edit' => 'edit',
2293  'download' => 'download',
2294  'upload' => 'upload',
2295  'create' => 'create',
2296  'change' => 'change',
2297  'save' => 'save',
2298  'set' => 'set',
2299  'reset' => 'reset',
2300  'relative' => 'Relative path to target',
2301  
2302  'yes' => 'Yes',
2303  'no' => 'No',
2304  'back' => 'back',
2305  'destination' => 'Destination',
2306  'symlink' => 'Symlink',
2307  'no_output' => 'no output',
2308  
2309  'user' => 'User',
2310  'password' => 'Password',
2311  'add' => 'add',
2312  'add_basic_auth' => 'add basic-authentification',
2313  
2314  'uploaded' => '"[%1]" has been uploaded.',
2315  'not_uploaded' => '"[%1]" could not be uploaded.',
2316  'already_exists' => '"[%1]" already exists.',
2317  'created' => '"[%1]" has been created.',
2318  'not_created' => '"[%1]" could not be created.',
2319  'really_delete' => 'Delete these files?',
2320  'deleted' => "These files have been deleted:\n[%1]",
2321  'not_deleted' => "These files could not be deleted:\n[%1]",
2322  'rename_file' => 'Rename file:',
2323  'renamed' => '"[%1]" has been renamed to "[%2]".',
2324  'not_renamed' => '"[%1] could not be renamed to "[%2]".',
2325  'move_files' => 'Move these files:',
2326  'moved' => "These files have been moved to \"[%2]\":\n[%1]",
2327  'not_moved' => "These files could not be moved to \"[%2]\":\n[%1]",
2328  'copy_files' => 'Copy these files:',
2329  'copied' => "These files have been copied to \"[%2]\":\n[%1]",
2330  'not_copied' => "These files could not be copied to \"[%2]\":\n[%1]",
2331  'not_edited' => '"[%1]" can not be edited.',
2332  'executed' => "\"[%1]\" has been executed successfully:\n{%2}",
2333  'not_executed' => "\"[%1]\" could not be executed successfully:\n{%2}",
2334  'saved' => '"[%1]" has been saved.',
2335  'not_saved' => '"[%1]" could not be saved.',
2336  'symlinked' => 'Symlink from "[%2]" to "[%1]" has been created.',
2337  'not_symlinked' => 'Symlink from "[%2]" to "[%1]" could not be created.',
2338  'permission_for' => 'Permission of "[%1]":',
2339  'permission_set' => 'Permission of "[%1]" was set to [%2].',
2340  'permission_not_set' => 'Permission of "[%1]" could not be set to [%2].',
2341  'not_readable' => '"[%1]" can not be read.'
2342          );
2343  
2344      }
2345  
2346  }
2347  
2348  function getimage ($image) {
2349      switch ($image) {
2350      case 'file':
2351          return base64_decode('R0lGODlhEQANAJEDAJmZmf///wAAAP///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
2352      case 'folder':
2353          return base64_decode('R0lGODlhEQANAJEDAJmZmf///8zMzP///yH5BAHoAwMALAAAAAARAA0AAAIqnI+ZwKwbYgTPtIudlbwLOgCBQJYmCYrn+m3smY5vGc+0a7dhjh7ZbygAADsA');
2354      case 'hidden_file':
2355          return base64_decode('R0lGODlhEQANAJEDAMwAAP///5mZmf///yH5BAHoAwMALAAAAAARAA0AAAItnIGJxg0B42rsiSvCA/REmXQWhmnih3LUSGaqg35vFbSXucbSabunjnMohq8CADsA');
2356      case 'link':
2357          return base64_decode('R0lGODlhEQANAKIEAJmZmf///wAAAMwAAP///wAAAAAAAAAAACH5BAHoAwQALAAAAAARAA0AAAM5SArcrDCCQOuLcIotwgTYUllNOA0DxXkmhY4shM5zsMUKTY8gNgUvW6cnAaZgxMyIM2zBLCaHlJgAADsA');
2358      case 'smiley':
2359          return base64_decode('R0lGODlhEQANAJECAAAAAP//AP///wAAACH5BAHoAwIALAAAAAARAA0AAAIslI+pAu2wDAiz0jWD3hqmBzZf1VCleJQch0rkdnppB3dKZuIygrMRE/oJDwUAOwA=');
2360      case 'arrow':
2361          return base64_decode('R0lGODlhEQANAIABAAAAAP///yH5BAEKAAEALAAAAAARAA0AAAIdjA9wy6gNQ4pwUmav0yvn+hhJiI3mCJ6otrIkxxQAOw==');
2362      }
2363  }
2364  
2365  function html_header () {
2366      global $site_charset;
2367  
2368      header('Content-Type: text/html; charset=utf-8');
2369      echo <<<END
2370  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2371       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2372  <html xmlns="http://www.w3.org/1999/xhtml">
2373  <head>
2374  
2375  <meta http-equiv="Content-Type" content="text/html; charset=$site_charset" />
2376  
2377  <title>webadmin.php</title>
2378  
2379  <style type="text/css">
2380  body { font: small sans-serif; text-align: center; width:100%; height:100%; padding:0px; margin:0px; }
2381  img { width: 17px; height: 13px }
2382  a, a:visited { text-decoration: none; color: navy }
2383  hr { border-style: none; height: 1px; background-color: silver; color: silver }
2384  #main { margin-top: 6pt; margin-left: auto; margin-right: auto; border-spacing: 1px }
2385  #main th { background: #eee; padding: 3pt 3pt 0pt 3pt }
2386  .listing th, .listing td { padding: 1px 3pt 0 3pt }
2387  .listing th { border: 1px solid silver }
2388  .listing td { border: 1px solid #ddd; background: white }
2389  .listing .checkbox { text-align: center }
2390  .listing .filename { text-align: left }
2391  .listing .size { text-align: right }
2392  .listing th.permission { text-align: left }
2393  .listing td.permission { font-family: monospace }
2394  .listing .owner { text-align: left }
2395  .listing .group { text-align: left }
2396  .listing .functions { text-align: left }
2397  .listing_footer td { background: #eee; border: 1px solid silver }
2398  #directory, #upload, #create, .listing_footer td, #error td, #notice td { text-align: left; padding: 3pt }
2399  #directory { background: #eee; border: 1px solid silver }
2400  #upload { padding-top: 1em }
2401  #create { padding-bottom: 1em }
2402  .small, .small option { font-size: x-small }
2403  textarea { border: none; background: white }
2404  table.dialog { margin-left: auto; margin-right: auto }
2405  td.dialog { background: #eee; padding: 1ex; border: 1px solid silver; text-align: center }
2406  #permission { margin-left: auto; margin-right: auto }
2407  #permission td { padding-left: 3pt; padding-right: 3pt; text-align: center }
2408  td.permission_action { text-align: right }
2409  #symlink { background: #eee; border: 1px solid silver }
2410  #symlink td { text-align: left; padding: 3pt }
2411  #red_button { width: 120px; color: #400 }
2412  #green_button { width: 120px; color: #040 }
2413  #error td { background: maroon; color: white; border: 1px solid silver }
2414  #notice td { background: green; color: white; border: 1px solid silver }
2415  #notice pre, #error pre { background: silver; color: black; padding: 1ex; margin-left: 1ex; margin-right: 1ex }
2416  code { font-size: 12pt }
2417  td { white-space: nowrap }
2418  </style>
2419  
2420  <script type="text/javascript">
2421  <!--
2422  function activate (name) {
2423      if (document && document.forms[0] && document.forms[0].elements['focus']) {
2424          document.forms[0].elements['focus'].value = name;
2425      }
2426  }
2427  function select_all(obj) {
2428    var elems = document.getElementsByTagName("input");
2429    for (var i=0; i < elems.length; i++) {
2430      if (elems[i].type=="checkbox") {
2431        elems[i].checked = obj.checked;
2432      }
2433    }
2434  }
2435  //-->
2436  </script>
2437  
2438  </head>
2439  <body>
2440  
2441  END;
2442  
2443  }
2444  
2445  function html_footer () {
2446  
2447      echo <<<END
2448  </body>
2449  </html>
2450  END;
2451  
2452  }
2453  
2454  function notice ($phrase) {
2455      global $cols;
2456  
2457      $args = func_get_args();
2458      array_shift($args);
2459  
2460      return '<tr id="notice">
2461      <td colspan="' . $cols . '">' . phrase($phrase, $args) . '</td>
2462  </tr>
2463  ';
2464  
2465  }
2466  
2467  function error ($phrase) {
2468      global $cols;
2469  
2470      $args = func_get_args();
2471      array_shift($args);
2472  
2473      return '<tr id="error">
2474      <td colspan="' . $cols . '">' . phrase($phrase, $args) . '</td>
2475  </tr>
2476  ';
2477  
2478  }
2479  
2480  ?>

title

Description

title

Description

title

Description

title

title

Body