| 1 | 
        
            4
         | 
        
            ryan
         | 
        <?php
  | 
      
      
        | 2 | 
        
         | 
        
         | 
        
  | 
      
      
        | 3 | 
        
         | 
        
         | 
        // $Id: create.php,v 1.10 2005/04/25 11:53:12 rdjurovich Exp $
  | 
      
      
        | 4 | 
        
         | 
        
         | 
        
  | 
      
      
        | 5 | 
        
         | 
        
         | 
        /*
  | 
      
      
        | 6 | 
        
         | 
        
         | 
        
  | 
      
      
        | 7 | 
        
         | 
        
         | 
         Website Baker Project <http://www.websitebaker.org/>
  | 
      
      
        | 8 | 
        
         | 
        
         | 
         Copyright (C) 2004-2005, Ryan Djurovich
  | 
      
      
        | 9 | 
        
         | 
        
         | 
        
  | 
      
      
        | 10 | 
        
         | 
        
         | 
         Website Baker is free software; you can redistribute it and/or modify
  | 
      
      
        | 11 | 
        
         | 
        
         | 
         it under the terms of the GNU General Public License as published by
  | 
      
      
        | 12 | 
        
         | 
        
         | 
         the Free Software Foundation; either version 2 of the License, or
  | 
      
      
        | 13 | 
        
         | 
        
         | 
         (at your option) any later version.
  | 
      
      
        | 14 | 
        
         | 
        
         | 
        
  | 
      
      
        | 15 | 
        
         | 
        
         | 
         Website Baker is distributed in the hope that it will be useful,
  | 
      
      
        | 16 | 
        
         | 
        
         | 
         but WITHOUT ANY WARRANTY; without even the implied warranty of
  | 
      
      
        | 17 | 
        
         | 
        
         | 
         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  | 
      
      
        | 18 | 
        
         | 
        
         | 
         GNU General Public License for more details.
  | 
      
      
        | 19 | 
        
         | 
        
         | 
        
  | 
      
      
        | 20 | 
        
         | 
        
         | 
         You should have received a copy of the GNU General Public License
  | 
      
      
        | 21 | 
        
         | 
        
         | 
         along with Website Baker; if not, write to the Free Software
  | 
      
      
        | 22 | 
        
         | 
        
         | 
         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  | 
      
      
        | 23 | 
        
         | 
        
         | 
        
  | 
      
      
        | 24 | 
        
         | 
        
         | 
        */
  | 
      
      
        | 25 | 
        
         | 
        
         | 
        
  | 
      
      
        | 26 | 
        
         | 
        
         | 
        // Get dir name and target location
  | 
      
      
        | 27 | 
        
         | 
        
         | 
        if(!isset($_POST['name']) OR $_POST['name'] == '') {
 | 
      
      
        | 28 | 
        
         | 
        
         | 
        	header("Location: index.php");
 | 
      
      
        | 29 | 
        
         | 
        
         | 
        } else {
 | 
      
      
        | 30 | 
        
         | 
        
         | 
        	$name = $_POST['name'];
  | 
      
      
        | 31 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 32 | 
        
         | 
        
         | 
        if(!isset($_POST['target']) OR $_POST['target'] == '') {
 | 
      
      
        | 33 | 
        
         | 
        
         | 
        	header("Location: index.php");
 | 
      
      
        | 34 | 
        
         | 
        
         | 
        } else {
 | 
      
      
        | 35 | 
        
         | 
        
         | 
        	$target = $_POST['target'];
  | 
      
      
        | 36 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 37 | 
        
         | 
        
         | 
        
  | 
      
      
        | 38 | 
        
         | 
        
         | 
        // Print admin header
  | 
      
      
        | 39 | 
        
         | 
        
         | 
        require('../../config.php');
 | 
      
      
        | 40 | 
        
         | 
        
         | 
        require_once(WB_PATH.'/framework/class.admin.php');
  | 
      
      
        | 41 | 
        
         | 
        
         | 
        $admin = new admin('Media', 'media_create');
 | 
      
      
        | 42 | 
        
         | 
        
         | 
        
  | 
      
      
        | 43 | 
        
         | 
        
         | 
        // Include the WB functions file
  | 
      
      
        | 44 | 
        
         | 
        
         | 
        require_once(WB_PATH.'/framework/functions.php');
  | 
      
      
        | 45 | 
        
         | 
        
         | 
        
  | 
      
      
        | 46 | 
        
         | 
        
         | 
        // Check to see if name or target contains ../
  | 
      
      
        | 47 | 
        
         | 
        
         | 
        if(strstr($name, '../')) {
 | 
      
      
        | 48 | 
        
         | 
        
         | 
        	$admin->print_error($MESSAGE['MEDIA']['NAME_DOT_DOT_SLASH']);
  | 
      
      
        | 49 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 50 | 
        
         | 
        
         | 
        if(strstr($target, '../')) {
 | 
      
      
        | 51 | 
        
         | 
        
         | 
        	$admin->print_error($MESSAGE['MEDIA']['TARGET_DOT_DOT_SLASH']);
  | 
      
      
        | 52 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 53 | 
        
         | 
        
         | 
        
  | 
      
      
        | 54 | 
        
         | 
        
         | 
        // Remove bad characters
  | 
      
      
        | 55 | 
        
         | 
        
         | 
        $name = media_filename($name);
  | 
      
      
        | 56 | 
        
         | 
        
         | 
        
  | 
      
      
        | 57 | 
        
         | 
        
         | 
        // Create relative path of the new dir name
  | 
      
      
        | 58 | 
        
         | 
        
         | 
        $relative = WB_PATH.$target.'/'.$name;
  | 
      
      
        | 59 | 
        
         | 
        
         | 
        
  | 
      
      
        | 60 | 
        
         | 
        
         | 
        // Check to see if the folder already exists
  | 
      
      
        | 61 | 
        
         | 
        
         | 
        if(file_exists($relative)) {
 | 
      
      
        | 62 | 
        
         | 
        
         | 
        	$admin->print_error($MESSAGE['MEDIA']['DIR_EXISTS']);
  | 
      
      
        | 63 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 64 | 
        
         | 
        
         | 
        
  | 
      
      
        | 65 | 
        
         | 
        
         | 
        // Try and make the dir
  | 
      
      
        | 66 | 
        
         | 
        
         | 
        if(make_dir($relative)) {
 | 
      
      
        | 67 | 
        
         | 
        
         | 
        	// Create index.php file
  | 
      
      
        | 68 | 
        
         | 
        
         | 
        	$content = ''.
  | 
      
      
        | 69 | 
        
         | 
        
         | 
        "<?php
  | 
      
      
        | 70 | 
        
         | 
        
         | 
        
  | 
      
      
        | 71 | 
        
         | 
        
         | 
        header('Location: ../');
 | 
      
      
        | 72 | 
        
         | 
        
         | 
        
  | 
      
      
        | 73 | 
        
         | 
        
         | 
        ?>";
  | 
      
      
        | 74 | 
        
         | 
        
         | 
        	$handle = fopen($relative.'/index.php', 'w');
  | 
      
      
        | 75 | 
        
         | 
        
         | 
        	fwrite($handle, $content);
  | 
      
      
        | 76 | 
        
         | 
        
         | 
        	fclose($handle);
  | 
      
      
        | 77 | 
        
         | 
        
         | 
        	change_mode($relative.'/index.php', 'file');
  | 
      
      
        | 78 | 
        
         | 
        
         | 
        	$admin->print_success($MESSAGE['MEDIA']['DIR_MADE']);
  | 
      
      
        | 79 | 
        
         | 
        
         | 
        } else {
 | 
      
      
        | 80 | 
        
         | 
        
         | 
        	$admin->print_error($MESSAGE['MEDIA']['DIR_NOT_MADE']);
  | 
      
      
        | 81 | 
        
         | 
        
         | 
        }
  | 
      
      
        | 82 | 
        
         | 
        
         | 
        
  | 
      
      
        | 83 | 
        
         | 
        
         | 
        // Print admin
  | 
      
      
        | 84 | 
        
         | 
        
         | 
        $admin->print_footer();
  | 
      
      
        | 85 | 
        
         | 
        
         | 
        
  | 
      
      
        | 86 | 
        
         | 
        
         | 
        ?>
  |