Source for file folders_rename_do.php

Documentation is available at folders_rename_do.php

  1. <?php
  2.  
  3. /**
  4.  * folders_rename_do.php
  5.  *
  6.  * Does the actual renaming of files on the IMAP server.
  7.  * Called from the folders.php
  8.  *
  9.  * @copyright 1999-2014 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: folders_rename_do.php 14436 2014-01-21 21:30:59Z pdontthink $
  12.  * @package squirrelmail
  13.  */
  14.  
  15. /** This is the folders_rename_do page */
  16. define('PAGE_NAME''folders_rename_do');
  17.  
  18. /**
  19.  * Path for SquirrelMail required files.
  20.  * @ignore
  21.  */
  22. define('SM_PATH','../');
  23.  
  24. /* SquirrelMail required files. */
  25. require_once(SM_PATH 'include/validate.php');
  26. require_once(SM_PATH 'functions/global.php');
  27. require_once(SM_PATH 'functions/imap.php');
  28. require_once(SM_PATH 'functions/display_messages.php');
  29.  
  30. /* globals */
  31. sqgetGlobalVar('key',       $key,           SQ_COOKIE);
  32. sqgetGlobalVar('username',  $username,      SQ_SESSION);
  33. sqgetGlobalVar('delimiter'$delimiter,     SQ_SESSION);
  34. sqgetGlobalVar('onetimepad',$onetimepad,    SQ_SESSION);
  35. sqgetGlobalVar('orig',      $orig,          SQ_POST);
  36. sqgetGlobalVar('old_name',  $old_name,      SQ_POST);
  37. sqgetGlobalVar('new_name',  $new_name,      SQ_POST);
  38. if (!sqgetGlobalVar('smtoken',$submitted_tokenSQ_POST)) {
  39.     $submitted_token '';
  40. }
  41. /* end globals */
  42.  
  43. // first, validate security token
  44. sm_validate_security_token($submitted_token-1TRUE);
  45.  
  46. $new_name trim($new_name);
  47.  
  48. if (substr_count($new_name'"'|| substr_count($new_name"\\"||
  49.     substr_count($new_name$delimiter|| ($new_name == '')) {
  50.     displayPageHeader($color'None');
  51.  
  52.     plain_error_message(_("Illegal folder name. Please select a different name.").
  53.         '<br /><a href="../src/folders.php">'._("Click here to go back").'</a>.'$color);
  54.  
  55.     exit;
  56. }
  57.  
  58. $orig imap_utf7_encode_local($orig);
  59. $old_name imap_utf7_encode_local($old_name);
  60. $new_name imap_utf7_encode_local($new_name);
  61.  
  62. if ($old_name <> $new_name{
  63.  
  64.     global $imap_stream_options// in case not defined in config
  65.     $imapConnection sqimap_login($username$key$imapServerAddress$imapPort0$imap_stream_options);
  66.  
  67.     if (strpos($orig$delimiter)) {
  68.         $old_dir substr($orig0strrpos($orig$delimiter));
  69.     else {
  70.         $old_dir '';
  71.     }
  72.  
  73.     if ($old_dir != ''{
  74.         $newone $old_dir $delimiter $new_name;
  75.     else {
  76.         $newone $new_name;
  77.     }
  78.  
  79.     // Renaming a folder doesn't rename the folder but leaves you unsubscribed
  80.     //    at least on Cyrus IMAP servers.
  81.     if (isset($isfolder)) {
  82.         $newone $newone.$delimiter;
  83.         $orig $orig.$delimiter;
  84.     }
  85.     sqimap_mailbox_rename$imapConnection$orig$newone );
  86.  
  87.     // Log out this session 
  88.     sqimap_logout($imapConnection);
  89.  
  90. }
  91.  
  92. header ('Location: ' get_location('/folders.php?success=rename');

Documentation generated on Tue, 29 Jul 2014 04:20:57 +0200 by phpDocumentor 1.4.3