Exemplo n.º 1
0
 function spawn()
 {
     // try to create directory if it doesn't exist'
     // added by David McReynolds @ Daylight Studio 9/16/10 to prevent problems of axing the entire directory
     if (!is_dir($this->_parser_compile_dir)) {
         @mkdir($this->_parser_compile_dir, 0777, TRUE);
         chmodr($this->_parser_compile_dir, 0777);
     }
     if (is_writable($this->_parser_compile_dir)) {
         // Main Dwoo object
         $dwoo = new Dwoo();
         // The directory where compiled templates are located
         $dwoo->setCompileDir($this->_parser_compile_dir);
         $dwoo->setCacheDir($this->_parser_cache_dir);
         $dwoo->setCacheTime($this->_parser_cache_time);
         // Security
         $security = new MY_Security_Policy();
         $security->setPhpHandling($this->_parser_allow_php_tags);
         $security->allowPhpFunction($this->_parser_allowed_php_functions);
         $dwoo->setSecurityPolicy($security);
         return $dwoo;
     }
 }
Exemplo n.º 2
0
/**
 * chmod recursively on a directory
 *
 * @param string $path
 * @param int $mode
 * @return boolean
 */
function chmodr($path, $mode = 0755)
{
    if (!is_dir($path)) {
        return chmod($path, $mode);
    }
    $dir = opendir($path);
    while ($file = readdir($dir)) {
        if ($file != '.' && $file != '..') {
            $fullpath = $path . '/' . $file;
            if (!is_dir($fullpath)) {
                if (!chmod($fullpath, $mode)) {
                    return false;
                }
            } else {
                if (!chmodr($fullpath, $mode)) {
                    return false;
                }
            }
        }
    }
    closedir($dir);
    if (chmod($path, $mode)) {
        return true;
    } else {
        return false;
    }
}
/**
 * Recursively changes the permissions of a folder structure
 *
 *  from php.net/chmod
 * @access	public
 * @param 	string
 * @param 	octal
 * @return	boolean
 */
function chmodr($path, $filemode)
{
    if (!is_dir($path)) {
        return chmod($path, $filemode);
    }
    $dh = opendir($path);
    while (($file = readdir($dh)) !== false) {
        if ($file != '.' and $file != '..') {
            $fullpath = $path . '/' . $file;
            if (is_link($fullpath)) {
                return FALSE;
            } elseif (!is_dir($fullpath) and !chmod($fullpath, $filemode)) {
                return FALSE;
            } elseif (!chmodr($fullpath, $filemode)) {
                return FALSE;
            }
        }
    }
    closedir($dh);
    if (chmod($path, $filemode)) {
        return TRUE;
    } else {
        return FALSE;
    }
}
Exemplo n.º 4
0
 /**
  * Looks for a skeleton template of a Cake application,
  * and if not found asks the user for a path. When there is a path
  * this method will make a deep copy of the skeleton to the project directory.
  * A default home page will be added, and the tmp file storage will be chmod'ed to 0777.
  *
  * @param string $projectPath
  * @param string $appName
  */
 function __buildDirLayout($projectPath, $appName)
 {
     $skel = '';
     if ($this->__checkPath(CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'scripts' . DS . 'templates' . DS . 'skel') === true) {
         $skel = CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'scripts' . DS . 'templates' . DS . 'skel';
     } else {
         while ($skel == '') {
             $skel = $this->getInput("What is the full path for the cake install app directory?\nExample: ", null, ROOT . 'myapp' . DS);
             if ($skel == '') {
                 $this->stdout('The directory path you supplied was empty. Please try again.');
             } else {
                 while ($this->__checkPath($skel) === false) {
                     $skel = $this->getInput('Directory path does not exist please choose another:');
                 }
             }
         }
     }
     $this->stdout('');
     $this->hr();
     $this->stdout("Skel Directory: {$skel}");
     $this->stdout("Will be copied to:");
     $this->stdout("New App Directory: {$projectPath}");
     $this->hr();
     $looksGood = $this->getInput('Look okay?', array('y', 'n', 'q'), 'y');
     if (low($looksGood) == 'y' || low($looksGood) == 'yes') {
         $verboseOuptut = $this->getInput('Do you want verbose output?', array('y', 'n'), 'n');
         $verbose = false;
         if (low($verboseOuptut) == 'y' || low($verboseOuptut) == 'yes') {
             $verbose = true;
         }
         $this->__copydirr($skel, $projectPath, 0755, $verbose);
         $this->hr();
         $this->stdout('Created: ' . $projectPath);
         $this->hr();
         $this->stdout('Creating welcome page');
         $this->hr();
         $this->__defaultHome($projectPath, $appName);
         $this->stdout('Welcome page created');
         if (chmodr($projectPath . DS . 'tmp', 0777) === false) {
             $this->stdout('Could not set permissions on ' . $projectPath . DS . 'tmp' . DS . '*');
             $this->stdout('You must manually check that these directories can be wrote to by the server');
         }
         return;
     } elseif (low($looksGood) == 'q' || low($looksGood) == 'quit') {
         $this->stdout('Bake Aborted.');
     } else {
         $this->project();
     }
 }
Exemplo n.º 5
0
 /**
 * Uploads the files in the $_FILES array
 *
 * Accepts an associative array as which can have the following parameters:
 *
 		<ul>
 		 	<li><strong>upload_path</strong>: the server path to upload the file</li>
 		 	<li><strong>override_post_params</strong>: determines whether post parameters (e.g. {$_FILES_key}_{param}) take precedence over parameters passed to the method</li>
 		 	<li><strong>file_name</strong>: the name of the file to change to</li>
 		 	<li><strong>overwrite</strong>: boolean value that determines whether to overwrite the file or create a new file which will append a number at the end</li>
 		 	<li><strong>xss_clean</strong>: boolean value that determines whether to try and run the xss_clean function on any images that are uploaded</li>
 		 	<li><strong>encrypt_name</strong>: boolean value that determines whether to encrypt the file name and make it unique</li>
 		 	<li><strong>create_thumb</strong>: image specific boolean value that determines whether to create a thumbnail image based on the original uploaded image</li>
 		 	<li><strong>thumb_marker</strong>: the default suffix to use on a generated thumbnail. The default is "_thumb"</li>
 		 	<li><strong>maintain_ratio</strong>:image specific boolean value that determines whether to maintain the aspect ratio of the image upon resize</li>
 		 	<li><strong>master_dim</strong>: image specific boolean value that determines which dimension should be used when resizing and maintaining the aspect ratio. Options are height, width, auto</li>
 		 	<li><strong>width</strong>: sets the width of the uploaded image</li>
 		 	<li><strong>height</strong>: sets the height of the uploaded image</li>
 		 	<li><strong>resize_and_crop</strong>: image specific boolean value that determines whether to both resize and crop the image to the specified height and width</li>
 		 </ul>
 *
 * @access	public
 * @param	array	upload parameters (optional)
 * @return	boolean
 */
 public function upload($params = array())
 {
     $this->CI->load->library('upload');
     $this->CI->load->library('image_lib');
     $this->CI->load->library('encrypt');
     $valid = array('upload_path' => '', 'file_name' => '', 'overwrite' => FALSE, 'xss_clean' => FALSE, 'encrypt_name' => FALSE, 'unzip' => FALSE, 'override_post_params' => FALSE, 'posted' => $_POST, 'create_thumb' => NULL, 'thumb_marker' => '_thumb', 'maintain_ratio' => NULL, 'master_dim' => NULL, 'width' => NULL, 'height' => NULL, 'resize_and_crop' => FALSE);
     // used later
     $has_empty_filename = empty($params['file_name']) ? TRUE : FALSE;
     // set defaults
     foreach ($valid as $param => $default) {
         $params[$param] = isset($params[$param]) ? $params[$param] : $default;
     }
     // upload the file
     foreach ($_FILES as $key => $file) {
         if ($file['error'] == 0) {
             $ext = end(explode('.', $file['name']));
             $field_name = current(explode('___', $key));
             // extract out multi file upload infor
             // loop through all the allowed file types that are accepted for the asset directory
             foreach ($this->dir_filetypes() as $dir => $types) {
                 $file_types = explode('|', strtolower($types));
                 if (in_array(strtolower($ext), $file_types)) {
                     $default_asset_dir = $dir;
                     break;
                 }
             }
             if (empty($default_asset_dir)) {
                 $this->_add_error(lang('upload_invalid_filetype'));
                 return FALSE;
             }
             $non_multi_key = current(explode('___', $key));
             $posted_filename = FALSE;
             // get params based on the posted variables
             if (empty($params['override_post_params'])) {
                 $posted = array();
                 foreach ($valid as $param => $default) {
                     if ($param != 'posted') {
                         $input_key = $non_multi_key . '_' . $param;
                         $input_key_arr = explode('--', $input_key);
                         $input_key = end($input_key_arr);
                         $field_name_arr = explode('--', $field_name);
                         $field_name = end($field_name_arr);
                         // decode encrypted file path values
                         if (isset($params['posted'][$input_key])) {
                             if ($input_key == $field_name . '_upload_path') {
                                 $posted['upload_path'] = $this->CI->encrypt->decode($params['posted'][$input_key]);
                                 foreach ($params['posted'] as $k => $p) {
                                     if (!is_array($p)) {
                                         $posted['upload_path'] = str_replace('{' . $k . '}', $p, $posted['upload_path']);
                                     }
                                 }
                                 // security check to make sure that no crazy paths are being generated
                                 $posted['upload_path'] = str_replace('..' . DIRECTORY_SEPARATOR, '', $posted['upload_path']);
                             } else {
                                 $posted[$param] = $params['posted'][$input_key];
                             }
                             if ($param == 'file_name') {
                                 $posted_filename = TRUE;
                             }
                         }
                     }
                 }
                 $params = array_merge($params, $posted);
                 unset($params['override_post_params'], $params['posted']);
             }
             $asset_dir = trim(str_replace(assets_server_path(), '', $params['upload_path']), '/');
             // set restrictions
             $params['max_size'] = $this->fuel->config('assets_upload_max_size');
             $params['max_width'] = $this->fuel->config('assets_upload_max_width');
             $params['max_height'] = $this->fuel->config('assets_upload_max_height');
             if ($this->dir_filetype($asset_dir)) {
                 $params['allowed_types'] = $this->dir_filetype($asset_dir);
             } else {
                 if ($this->dir_filetype($default_asset_dir)) {
                     $params['allowed_types'] = $this->dir_filetype($default_asset_dir);
                     $asset_dir = $default_asset_dir;
                 } else {
                     $params['allowed_types'] = 'jpg|jpeg|png|gif';
                     $asset_dir = $default_asset_dir;
                 }
             }
             // set the upload path
             if (empty($params['upload_path'])) {
                 $params['upload_path'] = !empty($params[$field_name . '_path']) ? $params[$field_name . '_path'] : assets_server_path() . $asset_dir . '/';
             }
             $params['remove_spaces'] = TRUE;
             // make directory if it doesn't exist and subfolder creation is allowed'
             if (!is_dir($params['upload_path']) and $this->fuel->config('assets_allow_subfolder_creation')) {
                 // will recursively create folder
                 @mkdir($params['upload_path'], 0777, TRUE);
                 if (!file_exists($params['upload_path'])) {
                     $this->_add_error(lang('upload_not_writable'));
                 } else {
                     chmodr($params['upload_path'], 0777);
                 }
             }
             // set file name
             if (!$posted_filename) {
                 if ($has_empty_filename and !empty($params[$field_name . '_file_name'])) {
                     $params['file_name'] = $params[$field_name . '_file_name'];
                 } else {
                     if ($has_empty_filename) {
                         $file_name = pathinfo($file['name'], PATHINFO_FILENAME);
                         $params['file_name'] = url_title($file_name, 'underscore', FALSE);
                     }
                 }
             }
             // set overwrite
             $params['overwrite'] = is_true_val($params['overwrite']);
             if (is_image_file($params['file_name']) and !empty($params['xss_clean'])) {
                 $tmp_file = file_get_contents($file['tmp_name']);
                 if (xss_clean($tmp_file, TRUE) === FALSE) {
                     $this->_add_error(lang('upload_invalid_filetype'));
                 }
             }
             // if errors, then we simply return FALSE at this point and don't continue any further processing'
             if ($this->has_errors()) {
                 return FALSE;
             }
             // UPLOAD!!!
             $this->CI->upload->initialize($params);
             if (!$this->CI->upload->do_upload($key)) {
                 $this->_add_error($this->CI->upload->display_errors('', ''));
             } else {
                 $this->_data[$key] = $this->CI->upload->data();
                 // set the file perm if necessary
                 if ($this->fuel->config('set_upload_file_perms') !== FALSE and function_exists('chmod') and is_integer($this->fuel->config('set_upload_file_perms'))) {
                     chmod($this->_data[$key]['full_path'], $this->fuel->config('set_upload_file_perms'));
                 }
             }
         }
     }
     // set maintain ration if it is set to maintain_ratio
     if (!empty($params['resize_method']) and $params['resize_method'] == 'maintain_ratio') {
         $params['maintain_ratio'] = TRUE;
     }
     // now loop through the uploaded files to do any further image processing
     foreach ($this->_data as $file) {
         if (is_image_file($file['file_name']) and (isset($params['create_thumb']) or isset($params['maintain_ratio']) or !empty($params['width']) or !empty($params['height']) or !empty($params['master_dim']) or !empty($params['resize_and_crop']) or !empty($params['resize_method']))) {
             $params['source_image'] = $file['full_path'];
             // cast
             $params['maintain_ratio'] = (bool) $params['maintain_ratio'];
             // to fix issues with resize and crop
             if (empty($params['create_thumb'])) {
                 $params['thumb_marker'] = '';
             }
             $this->CI->image_lib->initialize($params);
             // check for if they want just a resize or a resize AND crop
             if (!empty($params['resize_and_crop']) or !empty($params['resize_method']) and $params['resize_method'] == 'resize_and_crop') {
                 $resize = $this->CI->image_lib->resize_and_crop();
             } else {
                 $resize = $this->CI->image_lib->resize();
             }
             if (!$resize) {
                 $this->_add_error($this->CI->image_lib->display_errors());
             }
         } else {
             if (is_true_val($params['unzip']) and $file['file_ext'] == '.zip') {
                 // unzip the contents
                 $this->unzip($file['full_path']);
                 // then delete the zip file
                 $this->delete($file['full_path']);
             }
         }
     }
     if ($this->has_errors()) {
         return FALSE;
     }
     return TRUE;
 }
Exemplo n.º 6
0
 protected function _process_uploads($posted = NULL)
 {
     if (empty($posted)) {
         $posted = $_POST;
     }
     $this->lang->load('upload');
     $errors = FALSE;
     if (!empty($_FILES)) {
         $this->load->model('assets_model');
         $this->load->library('upload');
         $this->load->helper('directory');
         $config['max_size'] = $this->config->item('assets_upload_max_size', 'fuel');
         $config['max_width'] = $this->config->item('assets_upload_max_width', 'fuel');
         $config['max_height'] = $this->config->item('assets_upload_max_height', 'fuel');
         // loop through all asset types
         foreach ($_FILES as $file => $file_info) {
             if ($file_info['error'] == 0) {
                 // continue processing
                 $filename = $file_info['name'];
                 $filename_arr = explode('.', $filename);
                 $filename_no_ext = $filename_arr[0];
                 $ext = end($filename_arr);
                 $test_multi = explode('___', $file);
                 $is_multi = count($test_multi) > 1;
                 $multi_root = $test_multi[0];
                 foreach ($this->assets_model->get_dir_filetypes() as $key => $val) {
                     $file_types = explode('|', strtolower($val));
                     if (in_array(strtolower($ext), $file_types)) {
                         $asset_dir = $key;
                         break;
                     }
                 }
                 if (!empty($asset_dir)) {
                     // upload path
                     if (!empty($posted[$file . '_path'])) {
                         $config['upload_path'] = $posted[$file . '_path'];
                     } else {
                         if (!empty($posted[$multi_root . '_path'])) {
                             $config['upload_path'] = $posted[$multi_root . '_path'];
                         } else {
                             $config['upload_path'] = isset($upload_path) ? $upload_path : assets_server_path() . $asset_dir . '/';
                         }
                     }
                     if (!is_dir($config['upload_path']) and $this->config->item('assets_allow_subfolder_creation', 'fuel')) {
                         // will recursively create folder
                         //$old = umask(0)
                         @mkdir($config['upload_path'], 0777, TRUE);
                         if (!file_exists($config['upload_path'])) {
                             $errors = TRUE;
                             add_error(lang('upload_not_writable'));
                             $this->session->set_flashdata('error', lang('upload_not_writable'));
                         } else {
                             chmodr($config['upload_path'], 0777);
                         }
                         //umask($old);
                     }
                     // overwrite
                     if (!empty($posted[$file . '_overwrite'])) {
                         $config['overwrite'] = !empty($posted[$file . '_overwrite']);
                     } else {
                         if (!empty($posted[$multi_root . '_overwrite'])) {
                             $config['overwrite'] = !empty($posted[$multi_root . '_overwrite']);
                         } else {
                             $config['overwrite'] = TRUE;
                         }
                     }
                     // filename... lower case it for consistency
                     $config['file_name'] = url_title($filename, 'underscore', TRUE);
                     if (!empty($posted[$file . '_filename'])) {
                         $config['file_name'] = $posted[$file . '_filename'] . '.' . $ext;
                     } else {
                         if (!empty($posted[$multi_root . '_filename'])) {
                             $config['file_name'] = $posted[$multi_root . '_filename'] . '.' . $ext;
                         }
                     }
                     $config['allowed_types'] = $this->assets_model->get_dir_filetype($asset_dir) ? $this->assets_model->get_dir_filetype($asset_dir) : 'jpg|jpeg|png|gif';
                     $config['remove_spaces'] = TRUE;
                     //$config['xss_clean'] = TRUE; // causes problem with image if true... so we use the below method
                     $tmp_file = file_get_contents($file_info['tmp_name']);
                     if ($this->sanitize_images and $this->input->xss_clean($tmp_file, TRUE) === FALSE) {
                         $errors = TRUE;
                         add_error(lang('upload_invalid_filetype'));
                         $this->session->set_flashdata('error', lang('upload_invalid_filetype'));
                     }
                     if (!$errors) {
                         $this->upload->initialize($config);
                         if (!$this->upload->do_upload($file)) {
                             $errors = TRUE;
                             add_error(lang('upload_invalid_filetype'));
                             $this->session->set_flashdata('error', $this->upload->display_errors('', ''));
                         }
                     }
                 }
             }
         }
     }
     return !$errors;
 }
/**
 * chmodr
 * 
 * @param string $path path or filepath
 * @param int $filemode
 * @return bool
 * @version 1.0.0
 */
function chmodr($path = null, $filemode = 0777)
{
    if (!is_dir($path)) {
        return chmod($path, $filemode);
    }
    $dh = opendir($path);
    while (($file = readdir($dh)) !== false) {
        if ($file != '.' && $file != '..') {
            $fullpath = $path . '/' . $file;
            if (is_link($fullpath)) {
                return false;
            } else {
                if (!is_dir($fullpath) && !chmod($fullpath, $filemode)) {
                    return false;
                } else {
                    if (!chmodr($fullpath, $filemode)) {
                        return false;
                    }
                }
            }
        }
    }
    closedir($dh);
    if (chmod($path, $filemode)) {
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 8
0
 /**
  * Installs the modules
  *
  * @access	public
  * @return	boolean
  */
 public function install()
 {
     $cli = $this->installer->cli();
     if (!$cli->is_cli()) {
         return FALSE;
     }
     $module = strtolower($this->name());
     $this->installer->config($module);
     // $intro = array(
     // 	"The FUEL CMS installer is an easy way to setup the CMS with common configurations. It will do the following:",
     // 	"1) Automatically generate an encryption key for the fuel/application/config/config.php.",
     // 	"2) Enable the CMS admin by changing the 'admin_enabled' config value in fuel/application/config/MY_fuel.php.",
     // 	"3) Change the 'fuel_mode' config value in in fuel/application/config/MY_fuel.php to allow for pages to be created in the CMS.",
     // 	"4) Change the 'site_name' config value in the fuel/application/config/MY_fuel.php.",
     // 	"5) Setup your evironments fuel/application/config/environments.php.",
     // 	"6) Will make the fuel/application/logs, fuel/application/cache and assets/images folders writable.",
     // 	"7) Update the fuel/application/config/database.php file with the inputted values.",
     // 	"8) Create a database and install the fuel_schema.sql file using your local MySQL connection.\n",
     // );
     $cli->write(lang('install_cli_intro'));
     // add the encryption key
     $this->installer->change_config('config', '$config[\'encryption_key\'] = \'\';', '$config[\'encryption_key\'] = \'' . md5(uniqid()) . '\';');
     // change the admin to be enabled
     $this->installer->change_config('MY_fuel', '$config[\'admin_enabled\'] = FALSE;', '$config[\'admin_enabled\'] = TRUE;');
     // change the fuel_model to "auto"
     $this->installer->change_config('MY_fuel', '$config[\'fuel_mode\'] = \'views\';', '$config[\'fuel_mode\'] = \'auto\';');
     // change the site_name config value
     $site_name = $cli->prompt(lang('install_site_name'));
     $this->installer->change_config('MY_fuel', '$config[\'site_name\'] = \'My Website\';', '$config[\'site_name\'] = \'' . $site_name . '\';');
     // setup environments
     $staging_environment = $cli->prompt(lang('install_environments_testing'));
     $prod_environment = $cli->prompt(lang('install_environments_production'));
     $environment_search = "'development' => array('localhost*', '192.*', '*.dev'),\n\t\t\t\t);";
     $environment_replace = "'development' => array('localhost*', '192.*', '*.dev'),";
     if (!empty($staging_environment)) {
         $environment_replace .= "\n\t\t\t\t'testing' => array('" . implode("', '", preg_split('#\\s+#', str_replace(',', '', $staging_environment))) . "'),";
     }
     if (!empty($prod_environment)) {
         $environment_replace .= "\n\t\t\t\t'production' => array('" . implode("', '", preg_split('#\\s+#', str_replace(',', '', $prod_environment))) . "'),";
     }
     $environment_replace .= "\n\t\t\t\t);";
     $this->installer->change_config('environments', $environment_search, $environment_replace);
     // change file permissions for writable folders
     $perms = $cli->prompt(lang('install_permissions'));
     if (!empty($perms)) {
         $this->CI->load->helper('directory');
         $writable_folders = array(APPPATH . 'cache/', APPPATH . 'logs/', WEB_ROOT . 'assets/images/');
         $perms = intval($perms, 8);
         foreach ($writable_folders as $folder) {
             @chmodr($folder, $perms);
             if (!is_writable($folder)) {
                 $this->_add_error(lang('error_folder_not_writable', $folder));
             }
         }
     }
     // ask database questions
     $db_name = $cli->prompt(lang('install_db_name'));
     $db_user = $cli->prompt(lang('install_db_user'));
     $db_pwd = $cli->secret(lang('install_db_pwd'));
     // change database config
     if (!empty($db_name) and !empty($db_user) and !empty($db_pwd)) {
         $this->installer->change_config('database', '$db[\'default\'][\'username\'] = \'\';', '$db[\'default\'][\'username\'] = \'' . $db_user . '\';');
         $this->installer->change_config('database', '$db[\'default\'][\'password\'] = \'\';', '$db[\'default\'][\'password\'] = \'' . $db_pwd . '\';');
         // now check the database connection and see if the database exists yet or not... if not create it
         $this->CI->load->dbutil();
         if (!$this->CI->dbutil->database_exists($db_name)) {
             $this->CI->load->dbforge();
             $this->CI->dbforge->create_database($db_name);
             $this->installer->change_config('database', '$db[\'default\'][\'database\'] = \'\';', '$db[\'default\'][\'database\'] = \'' . $db_name . '\';');
             $this->installer->install_sql();
         } else {
             // must do this afterward to prevent errors
             $this->installer->change_config('database', '$db[\'default\'][\'database\'] = \'\';', '$db[\'default\'][\'database\'] = \'' . $db_name . '\';');
         }
     }
     $cli->write("\n...\n");
     if ($this->has_errors()) {
         $cli->write(lang('install_success_with_errors', implode("\n", $this->fuel->errors())));
     } else {
         $cli->write(lang('install_success'));
     }
     $cli->new_line();
     $cli->write(lang('install_further_info'));
     return TRUE;
 }
Exemplo n.º 9
0
/**
 * See Folder::chmod
 *
 * @deprecated
 */
function chmodr($path, $mode = 0755)
{
    trigger_error("Deprecated. See Folder::chmod()", E_USER_ERROR);
    if (!is_dir($path)) {
        return chmod($path, $mode);
    }
    $dir = opendir($path);
    while ($file = readdir($dir)) {
        if ($file != '.' && $file != '..') {
            $fullpath = $path . '/' . $file;
            if (!is_dir($fullpath)) {
                if (!chmod($fullpath, $mode)) {
                    return false;
                }
            } else {
                if (!chmodr($fullpath, $mode)) {
                    return false;
                }
            }
        }
    }
    closedir($dir);
    if (chmod($path, $mode)) {
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 10
0
 /**
  * Creates the compile dir if possible in case it doesn't exist
  *
  * @access	public
  * @return	bool
  */
 public function create_compile_dir()
 {
     // try to create directory if it doesn't exist'
     if (!is_dir($this->compile_dir)) {
         $this->CI->load->helper('directory');
         $created = @mkdir($this->compile_dir, $this->compile_dir_perms, TRUE);
         chmodr($this->compile_dir, $this->compile_dir_perms);
         return $created;
     }
     return FALSE;
 }