home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / bookmarks / bookmark.php next >
PHP Script  |  2004-03-08  |  3KB  |  129 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. require("../../Group-Office.php");
  14. $GO_SECURITY->authenticate();
  15. require($GO_LANGUAGE->get_language_file('bookmarks'));
  16.  
  17. $GO_MODULES->authenticate('bookmarks');
  18.  
  19. require($GO_CONFIG->class_path."bookmarks.class.inc");
  20. $bookmarks = new bookmarks();
  21.  
  22.  
  23. if ($_SERVER['REQUEST_METHOD'] == "POST")
  24. {
  25.  
  26.     $URL = trim($_REQUEST['URL']);
  27.     $name = trim($_REQUEST['name']);
  28.     $invalid[] = "\"";
  29.     $invalid[] = "&";
  30.     $invalid[] = "?";
  31.  
  32.     if (!validate_input($name,$invalid))
  33.     {
  34.         $feedback = "<p class=\"Error\">".$invalid_chars.": \" & ?</p>";
  35.     }else
  36.     {
  37.         if ($URL != "" && $name != "")
  38.         {
  39.             if (!eregi('(^http[s]*:[/]+)(.*)', $URL))
  40.             {
  41.                 $URL= "http://".$URL;
  42.             }
  43.  
  44.             $new_window = isset($_REQUEST['new_window']) ? $_REQUEST['new_window'] : 0;
  45.  
  46.             if (isset($_REQUEST['bookmark_id']))
  47.             {
  48.                 if(!$bookmarks->update_bookmark($_REQUEST['bookmark_id'], $URL, $name, $new_window))
  49.                 {
  50.                     $feedback = "<p class=\"Error\">".$strSaveError."</p>";
  51.                 }else
  52.                 {
  53.                     header('Location: '.$GO_MODULES->url);
  54.                     exit();
  55.                 }
  56.             }else
  57.             {
  58.                 if(!$bookmarks->add_bookmark($GO_SECURITY->user_id, $URL, $name, $new_window))
  59.                 {
  60.                     $feedback = "<p class=\"Error\">".$strSaveError."</p>";
  61.                 }else
  62.                 {
  63.                     header('Location: '.$GO_MODULES->url);
  64.                     exit();
  65.                 }
  66.             }
  67.         }else
  68.         {
  69.             $feedback = "<p class=\"Error\">".$error_missing_field."</p>";
  70.         }
  71.     }
  72. }
  73. require($GO_THEME->theme_path."header.inc");
  74. ?>
  75. <form name="add" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  76. <?php
  77. if (isset($_REQUEST['bookmark_id']))
  78. {
  79.     echo '<input type="hidden" value="'.$_REQUEST['bookmark_id'].'" name="bookmark_id" />';
  80.  
  81.     $bookmark = $bookmarks->get_bookmark($_REQUEST['bookmark_id']);
  82.     $name = $bookmark['name'];
  83.     $URL = $bookmark['URL'];
  84.     $check = $bookmark['new_window'] == '1' ? true : false;
  85. }else
  86. {
  87.     $name = isset($_POST['name']) ? $_POST['name'] : '';
  88.     $URL = isset($_POST['URL']) ? $_POST['URL'] : 'http://';
  89.     $check = isset($_POST['new_window']) ? true : false;
  90. }
  91. $tabtable = new tabtable('bookmarks_tab', $lang_modules['bookmarks'], '300', '120', '120', '', true);
  92. $tabtable->print_head();
  93.  
  94. if (isset($feedback)) echo $feedback;
  95. ?>
  96. <table border="0" cellpadding="0" cellspacing="3">
  97. <tr>
  98.     <td><?php echo $strName; ?>:</td>
  99.     <td><input type="text" class="textbox" size="50" name="name" maxlength="50" value="<?php echo $name; ?>" /></td>
  100. </tr>
  101. <tr>
  102.     <td>URL:</td>
  103.     <td><input type="text" class="textbox" size="50" name="URL" maxlength="200" value="<?php echo $URL; ?>" /></td>
  104. </tr>
  105. <tr>
  106.     <td colspan="2">
  107.     <?php
  108.     $checkbox = new checkbox('new_window', 'true', $bm_new_window, $check);
  109.     ?>
  110.     </td>
  111. </tr>
  112. <tr>
  113.     <td colspan="2" align="center" height="20" valign="bottom">
  114.     <?php
  115.     $button = new button($cmdOk, 'javascript:document.forms[0].submit()');
  116.     echo '  ';
  117.     $button = new button($cmdClose, "javascript:document.location='".$GO_MODULES->url."index.php'");
  118.     ?>
  119.     </td>
  120. </tr>
  121. </table>
  122.  
  123. </form>
  124. <?php
  125. $tabtable->print_foot();
  126. require($GO_THEME->theme_path."footer.inc");
  127. ?>
  128.  
  129.