Ignore:
Timestamp:
Jul 7, 2013, 1:28:12 PM (11 years ago)
Author:
mistic100
Message:

bug:2898 make some updates methods static + factorize code from plugins, themes & languages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/themes.class.php

    r23248 r23821  
    222222        }
    223223
    224         if (!$this->deltree(PHPWG_THEMES_PATH.$theme_id))
    225         {
    226           $this->send_to_trash(PHPWG_THEMES_PATH.$theme_id);
    227         }
     224        deltree(PHPWG_THEMES_PATH.$theme_id, PHPWG_THEMES_PATH . 'trash');
    228225        break;
    229226
     
    642639                  elseif (is_dir($path))
    643640                  {
    644                     if (!$this->deltree($path))
    645                     {
    646                       $this->send_to_trash($path);
    647                     }
     641                    deltree($path, PHPWG_THEMES_PATH . 'trash');
    648642                  }
    649643                }
     
    665659
    666660  /**
    667    * delete $path directory
    668    * @param string - path
    669    */
    670   function deltree($path)
    671   {
    672     if (is_dir($path))
    673     {
    674       $fh = opendir($path);
    675       while ($file = readdir($fh))
    676       {
    677         if ($file != '.' and $file != '..')
    678         {
    679           $pathfile = $path . '/' . $file;
    680           if (is_dir($pathfile))
    681           {
    682             $this->deltree($pathfile);
    683           }
    684           else
    685           {
    686             @unlink($pathfile);
    687           }
    688         }
    689       }
    690       closedir($fh);
    691       return @rmdir($path);
    692     }
    693   }
    694 
    695   /**
    696    * send $path to trash directory
    697    * @param string - path
    698    */
    699   function send_to_trash($path)
    700   {
    701     $trash_path = PHPWG_THEMES_PATH . 'trash';
    702     if (!is_dir($trash_path))
    703     {
    704       @mkdir($trash_path);
    705       $file = @fopen($trash_path . '/.htaccess', 'w');
    706       @fwrite($file, 'deny from all');
    707       @fclose($file);
    708     }
    709     while ($r = $trash_path . '/' . md5(uniqid(rand(), true)))
    710     {
    711       if (!is_dir($r))
    712       {
    713         @rename($path, $r);
    714         break;
    715       }
    716     }
    717   }
    718 
    719   /**
    720661   * Sort functions
    721662   */
Note: See TracChangeset for help on using the changeset viewer.