Пример #1
0
 private function _try_create_missing_folders($folders, $url)
 {
     $permissions = array(0755, 0775, 0777);
     $prev_perm = w3_get_file_permissions(WP_CONTENT_DIR);
     foreach ($permissions as $permission) {
         $result = true;
         if ($prev_perm > $permission) {
             continue;
         }
         if ($permission != $prev_perm) {
             if (!($result = @chmod(WP_CONTENT_DIR, $permission))) {
                 $result = w3_chmod_dir(WP_CONTENT_DIR, $permission);
             }
         }
         if ($result) {
             try {
                 w3_wp_create_folders($folders, '', $url);
                 return true;
             } catch (Exception $ex) {
             }
         }
         if ($permission != $prev_perm) {
             if (!@chmod(WP_CONTENT_DIR, $prev_perm)) {
                 w3_chmod_dir(WP_CONTENT_DIR, $prev_perm);
             }
         }
     }
     return true;
 }
Пример #2
0
/**
 * Creates cache folder and extension files.
 * Throws exception on failure.
 *
 * @throws Exception
 */
function w3_activation_create_required_files()
{
    /**
     * Check installation files
     */
    $files = array(W3TC_INSTALL_FILE_ADVANCED_CACHE, W3TC_INSTALL_FILE_DB, W3TC_INSTALL_FILE_OBJECT_CACHE);
    $nonexistent_files = array();
    foreach ($files as $file) {
        if (!file_exists($file)) {
            $nonexistent_files[] = $file;
        }
    }
    if (count($nonexistent_files)) {
        throw new Exception(sprintf('Unfortunately core file(s): (<strong>%s</strong>) ' . 'are missing, so activation will fail. Please re-start the installation ' . 'process from the beginning.', implode(', ', $nonexistent_files)));
    }
    $directories = array(W3TC_CACHE_DIR, W3TC_CONFIG_DIR, W3TC_CACHE_CONFIG_DIR, W3TC_CACHE_TMP_DIR);
    try {
        w3_wp_create_folders($directories, 'direct');
    } catch (Exception $ex) {
    }
}