home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / bookmarks / save_bookmark.php < prev   
PHP Script  |  2004-03-08  |  4KB  |  131 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. require($GO_THEME->theme_path."simple_header.inc");
  18. if ($_SERVER['REQUEST_METHOD'] == "POST")
  19. {
  20.     require($GO_CONFIG->class_path."bookmarks.class.inc");
  21.     $bookmarks = new bookmarks();
  22.     $URL = trim($_REQUEST['URL']);
  23.     $name = trim($_REQUEST['name']);
  24.     $invalid[] = "\"";
  25.     $invalid[] = "&";
  26.     $invalid[] = "?";
  27.  
  28.     if (!validate_input($name,$invalid))
  29.     {
  30.         $feedback = "<p class=\"Error\">".$invalid_chars.": \" & ?</p>";
  31.     }else
  32.     {
  33.         if ($URL != "" && $name != "")
  34.         {
  35.             if (!eregi('(^http[s]*:[/]+)(.*)', $URL))
  36.             $URL= "http://".$URL;
  37.             if ($_REQUEST['bookmark_id'])
  38.             {
  39.                 if($bookmarks->update_bookmark($_REQUEST['bookmark_id'], $URL, $name, $_REQUEST['new_window']))
  40.                 {
  41.                     echo "<script type=\"text/javascript\">\nopener.location=opener.location\nwindow.close()\n</script>";
  42.                 }else
  43.                 {
  44.                     $feedback = "<p class=\"Error\">".$strSaveError."</p>";
  45.                 }
  46.             }else
  47.             {
  48.                 if($bookmarks->add_bookmark($GO_SECURITY->user_id, $URL, $name, $_REQUEST['new_window']))
  49.                 {
  50.                     echo "<script type=\"text/javascript\">\nopener.location=opener.location\nwindow.close()\n</script>";
  51.                 }else
  52.                 {
  53.                     $feedback = "<p class=\"Error\">".$strSaveError."</p>";
  54.                 }
  55.             }
  56.         }else
  57.         {
  58.             $feedback = "<p class=\"Error\">".$error_missing_field."</p>";
  59.         }
  60.     }
  61. }
  62. ?>
  63.  
  64. <form name="add" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  65. <?php
  66. $check = true;
  67. if (isset($_REQUEST['bookmark_id']))
  68. {
  69.     echo "<input type=\"hidden\" value=\"".$_REQUEST['bookmark_id']."\" name=\"bookmark_id\" />\n";
  70.         if ($_REQUEST['new_window'] != 1)
  71.         {
  72.                 $check =false;
  73.         }
  74. }
  75. ?>
  76. <table border="0" cellpadding="10" cellspacing="0" align="center" valign="center">
  77. <tr>
  78.     <td>
  79.     <table border="0" cellpadding="0" cellspacing="3">
  80.     <tr>
  81.         <td colspan="2" valign="top">
  82.         <h1><?php echo $bm_save_title; ?></h1>
  83.         <?php if (isset($feedback)) echo $feedback; ?>
  84.         </td>
  85.     </tr>
  86.     <tr>
  87.         <td>URL:</td>
  88.         <td><input type="text" class="textbox" size="50" name="URL" maxlength="200" value="<?php if(isset($_REQUEST['bURL'])) echo $_REQUEST['bURL']; ?>" /></td>
  89.     </tr>
  90.     <tr>
  91.         <td><?php echo $strName; ?>:</td>
  92.         <td><input type="text" class="textbox" size="50" name="name" maxlength="50" value="<?php if(isset($_REQUEST['bname'])) echo smartstrip($_REQUEST['bname']); ?>" /></td>
  93.     </tr>
  94.     <tr>
  95.         <td colspan="2">
  96.         <?php 
  97.         $checkbox = new checkbox('new_window', 'true', $bm_new_window, $check);
  98.         ?> 
  99.         </td>
  100.     </tr>
  101.     <tr>
  102.         <td colspan="2" align="center" height="20" valign="bottom">
  103.         <?php
  104.         $button = new button($cmdOk, 'javascript:document.forms[0].submit()');
  105.         echo '  ';
  106.         $button = new button($bm_current_page, 'javascript:get_current_page()');
  107.         echo '  ';
  108.         $button = new button($cmdCancel, 'javascript:window.close()');
  109.         ?>
  110.         </td>
  111.     </tr>
  112.     </table>
  113.     </td>
  114. </tr>
  115. </table>
  116. </form>
  117. <script type="text/javascript" language="javascript">
  118. <!--
  119.     function get_current_page()
  120.     {
  121.         document.add.URL.value=opener.location;
  122.         document.add.name.value=opener.document.title;
  123.     }
  124.     document.forms[0].URL.focus();
  125. -->
  126. </script>
  127. <?php
  128. require($GO_THEME->theme_path."simple_footer.inc");
  129. ?>
  130.  
  131.