Changeset 602441
- Timestamp:
- 09/22/2012 05:53:34 PM (14 years ago)
- Location:
- edge-suite/trunk
- Files:
-
- 7 edited
-
admin/manage.php (modified) (2 diffs)
-
admin/options.php (modified) (3 diffs)
-
edge-suite.php (modified) (5 diffs)
-
includes/edge-suite-comp-builder.inc (modified) (3 diffs)
-
includes/edge-suite-comp.inc (modified) (3 diffs)
-
includes/edge-suite-general.php (modified) (3 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
edge-suite/trunk/admin/manage.php
r594166 r602441 58 58 59 59 // Init file system 60 WP_Filesystem(); 60 // Todo: this doesn't work with FTP 61 //WP_Filesystem(); 61 62 62 63 $tmp_file = EDGE_SUITE_PUBLIC_DIR . '/tmp/' . $_FILES['edge_suite_composition_upload']['name']; … … 93 94 <h2>Edge Suite - Manage compositions</h2> 94 95 96 <?php 97 $msg = check_filesystem(); 98 if(!empty($msg)){ 99 echo '<div class="error"><p>'; 100 echo implode('</br>',$msg); 101 echo '</p></div>'; 102 } 103 ?> 95 104 96 <h3>Upload new composition</h3>105 <h3>Upload new composition</h3> 97 106 <form enctype="multipart/form-data" action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="POST"> 98 107 <input name="edge_suite_composition_upload" type="file" /> -
edge-suite/trunk/admin/options.php
r587841 r602441 6 6 <?php settings_fields('edge_suite_options'); ?> 7 7 <table class="form-table"> 8 9 <tr valign="top">10 <th scope="row">Max upload file size</th>11 <td>12 <input type="text" name="edge_suite_max_size"13 value="<?php echo get_option('edge_suite_max_size'); ?>"/>14 <span class="setting-description">15 File size in MB<br/>This is the max size that your file uploads will be limited to. 2 MB is the default upload size.16 </span>17 </td>18 </tr>19 20 8 21 9 <tr valign="top"> … … 48 36 </tr> 49 37 38 <tr valign="top"> 39 <th scope="row">Max upload file size</th> 40 <td> 41 <input type="text" name="edge_suite_max_size" 42 value="<?php echo intval(get_option('edge_suite_max_size')); ?>"/> 43 <span class="setting-description"> 44 File size in MB<br/>This is the max size that your file uploads will be limited to. 2 MB is the default upload size. 45 </span> 46 </td> 47 </tr> 48 49 <tr valign="top"> 50 <th scope="row">Deactivation deletion</th> 51 <td> 52 <?php 53 $selected = intval(get_option('edge_suite_deactivation_delete')) == 1 ? 'checked="checked"' : ''; 54 ?> 55 <p><input type="checkbox" name="edge_suite_deactivation_delete" value="1" <?php echo $selected; ?>"/> 56 Delete Edge Suite assets and settings on plugin deactivation</p> 57 <span class="setting-description"> 58 Activate this option to delete all uploaded compositions (files and database entries) including all Edge Suite 59 settings from wordpress when deactivating the plugin. This should be activated if you are unable to delete files 60 manually through FTP and want to clean out Edge Suite completely. 61 </span> 62 </td> 63 </tr> 64 50 65 51 66 </table> … … 53 68 <input type="hidden" name="action" value="update"/> 54 69 <input type="hidden" name="page_options" 55 value="edge_suite_max_size,edge_suite_comp_default,edge_suite_comp_homepage "/>70 value="edge_suite_max_size,edge_suite_comp_default,edge_suite_comp_homepage,edge_suite_deactivation_delete"/> 56 71 57 72 <p class="submit"> -
edge-suite/trunk/edge-suite.php
r594166 r602441 2 2 /* 3 3 Plugin Name: Edge Suite 4 Plugin URI: http:// timm-jansen.net/edge_suite_wp4 Plugin URI: http://edgedocks.com/edge_suite 5 5 Description: Upload Adobe Edge compositions to your website. 6 6 Author: Timm Jansen 7 7 Author URI: http://timm-jansen.net/ 8 Version: 0. 18 Version: 0.2 9 9 */ 10 10 … … 28 28 /** 29 29 * This is a port of the Drupal Edge Suite module (done by me as well) for wordpress. 30 */30 */ 31 31 32 32 require_once('includes/edge-suite-general.php'); 33 33 require_once('includes/edge-suite-comp.inc'); 34 35 /** 36 * Set all needed constants 37 */ 38 function edge_suite_init_constants(){ 39 // Respect general upload path. 40 $upload_dir = get_option('upload_path'); 41 if (empty($upload_dir)) { 42 $upload_dir = 'wp-content/uploads'; 43 } 44 $upload_dir = untrailingslashit($upload_dir); 45 46 define('EDGE_SUITE_PUBLIC_DIR_REL', get_bloginfo('wpurl') . '/' . $upload_dir . '/edge_suite'); 47 define('EDGE_SUITE_PUBLIC_DIR', untrailingslashit(ABSPATH) . '/' . $upload_dir . '/edge_suite'); 48 49 define('EDGE_SUITE_COMP_PROJECT_DIR', EDGE_SUITE_PUBLIC_DIR . '/project'); 50 define('EDGE_SUITE_COMP_PROJECT_DIR_REL', EDGE_SUITE_PUBLIC_DIR_REL . '/project'); 51 52 53 define('EDGE_SUITE_ALLOWED_ASSET_EXTENSIONS', 'js|png|jpg|gif|svg|css'); 54 55 56 define('REQUEST_TIME', time()); 57 58 } 34 59 35 60 /*** UN/INSTALL ***/ … … 61 86 // Default options. 62 87 add_option('edge_suite_max_size', 2); 63 add_option('edge_suite_comp_default', 0);88 add_option('edge_suite_comp_default', -1); 64 89 add_option('edge_suite_comp_homepage', 0); 90 add_option('edge_suite_deactivation_delete', 0); 91 92 // Create main edge suite directory. 93 mkdir_recursive(trailingslashit(EDGE_SUITE_PUBLIC_DIR)); 65 94 } 66 95 … … 69 98 70 99 function edge_suite_uninstall() { 71 global $wpdb; 72 $table_name = $wpdb->prefix . "edge_suite_composition_definition"; 73 if ($wpdb->get_var("show tables like '$table_name'") == $table_name) { 74 $wpdb->query('DROP TABLE ' . $table_name); 75 } 76 // Todo: Delete all edge directories / options / meta data? 100 if(get_option('edge_suite_deactivation_delete') == 1){ 101 edge_suite_init_constants(); 102 103 global $wpdb; 104 $table_name = $wpdb->prefix . "edge_suite_composition_definition"; 105 if ($wpdb->get_var("show tables like '$table_name'") == $table_name) { 106 $wpdb->query('DROP TABLE ' . $table_name); 107 } 108 109 // Delete all edge directories 110 rmdir_recursive(trailingslashit(EDGE_SUITE_PUBLIC_DIR)); 111 112 // Delete options 113 delete_option('edge_suite_max_size'); 114 delete_option('edge_suite_comp_default'); 115 delete_option('edge_suite_comp_homepage'); 116 delete_option('edge_suite_deactivation_delete'); 117 } 77 118 } 78 119 79 120 register_deactivation_hook(__FILE__, 'edge_suite_uninstall'); 80 81 82 /** 83 * Register general options. 84 */ 121 //register_uninstall_hook(__FILE__, 'edge_suite_uninstall'); 122 123 124 /** 125 * Register general options. 126 */ 85 127 function edge_suite_options_init() { 86 128 register_setting('edge_suite_options', 'edge_suite_max_size'); 87 129 register_setting('edge_suite_options', 'edge_suite_comp_default'); 88 130 register_setting('edge_suite_options', 'edge_suite_comp_homepage'); 131 register_setting('edge_suite_options', 'edge_suite_deactivation_delete'); 89 132 } 90 133 91 134 add_action('admin_init', 'edge_suite_options_init'); 135 92 136 93 137 … … 101 145 $edge_suite->msg = array(); 102 146 103 // Respect general upload path. 104 $upload_dir = get_option('upload_path'); 105 if (empty($upload_dir)) { 106 $upload_dir = 'wp-content/uploads'; 107 } 108 109 define('EDGE_SUITE_PUBLIC_DIR_REL', get_bloginfo('wpurl') . '/' . $upload_dir . '/edge_suite'); 110 define('EDGE_SUITE_PUBLIC_DIR', ABSPATH . '/' . $upload_dir . '/edge_suite'); 111 112 define('EDGE_SUITE_COMP_PROJECT_DIR', EDGE_SUITE_PUBLIC_DIR . '/project'); 113 define('EDGE_SUITE_COMP_PROJECT_DIR_REL', EDGE_SUITE_PUBLIC_DIR_REL . '/project'); 147 edge_suite_init_constants(); 114 148 115 149 //Check if dir is writable and create directory structure. 116 150 if (!mkdir_recursive(EDGE_SUITE_COMP_PROJECT_DIR)) { 117 $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), EDGE_SUITE_COMP_PROJECT_DIR_REL); 118 return array('error' => $message); 119 } 120 121 define('REQUEST_TIME', time()); 151 print sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), EDGE_SUITE_COMP_PROJECT_DIR_REL); 152 } 153 122 154 } 123 155 -
edge-suite/trunk/includes/edge-suite-comp-builder.inc
r594166 r602441 325 325 326 326 // Get archiver. 327 $success = unzip _file($file, $destination);328 if ( !$success) {329 throw new Exception('Extraction of ' . $file . ' failed.');327 $success = unzip($file, $destination); 328 if (is_wp_error($success)) { 329 throw new Exception('Extraction of ' . $file . ' failed.'); 330 330 } 331 331 } … … 535 535 536 536 if ($overwrite || !$exists) { 537 $moved = $wp_filesystem->move($lib->uri, $this->edgeDir . '/edge_includes/' . $lib->filename, TRUE);537 $moved = move_file($lib->uri, $this->edgeDir . '/edge_includes/' . $lib->filename); 538 538 if (!$moved) { 539 539 set_message('Library ' . check_plain($lib->filename) . ' could not be added/moved.'); … … 604 604 // TODO: Feedback if file couldn't be moved. 605 605 $file_info = pathinfo($f); 606 $moved = $wp_filesystem->move($f, $dest . '/' . $rel_dir . '/' . $file_info['basename']);606 $moved = move_file($f, $dest . '/' . $rel_dir . '/' . $file_info['basename']); 607 607 } 608 608 } -
edge-suite/trunk/includes/edge-suite-comp.inc
r594166 r602441 89 89 90 90 $project_path = EDGE_SUITE_COMP_PROJECT_DIR . '/' . $def_name; 91 rename($project_tmp_path, $project_path);91 move_file($project_tmp_path, $project_path); 92 92 93 93 $success = TRUE; … … 95 95 } catch (Exception $e) { 96 96 // Clean out all files. 97 print $e->getMessage();98 97 99 98 // Make sure source extraction directory gets cleaned out. … … 107 106 rmdir_recursive($project_path); 108 107 } 108 109 // Hand exception to the next level. 110 throw new Exception($e->getMessage()); 109 111 // TODO: Libraries might have been copied. Critical? 110 112 } -
edge-suite/trunk/includes/edge-suite-general.php
r594166 r602441 1 1 <?php 2 2 3 4 5 // Not used yet 6 function fs_connect( $directories = array() ) { 7 global $wp_filesystem; 8 9 $url = "edge_suite"; 10 if ( false === ($credentials = request_filesystem_credentials($url)) ) 11 return false; 12 13 if ( ! WP_Filesystem($credentials) ) { 14 $error = true; 15 if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() ) 16 $error = $wp_filesystem->errors; 17 $this->skin->request_filesystem_credentials($error); //Failed to connect, Error and request again 18 return false; 19 } 20 21 if ( ! is_object($wp_filesystem) ) 22 return new WP_Error('fs_unavailable', $this->strings['fs_unavailable'] ); 23 24 if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) 25 return new WP_Error('fs_error', $this->strings['fs_error'], $wp_filesystem->errors); 26 27 foreach ( (array)$directories as $dir ) { 28 if ( ! $wp_filesystem->find_folder($dir) ) 29 return new WP_Error('fs_no_folder', sprintf($this->strings['fs_no_folder'], $dir)); 30 } 31 return true; 32 } 33 34 function check_filesystem(){ 35 $msg = array(); 36 if(!class_exists('ZipArchive')){ 37 $msg['zip'] = 'Your server is not able to extract zip files (PHP Class "ZipArchive" not found).'; 38 } 39 40 // Check file system method 41 42 $method = null; 43 $fs_msg = ''; 44 if ( function_exists('getmyuid') && function_exists('fileowner') ){ 45 $context = trailingslashit(EDGE_SUITE_PUBLIC_DIR); 46 $temp_file_name = $context . 'temp-write-test-edge-' . time(); 47 $temp_handle = @fopen($temp_file_name, 'w'); 48 if ( $temp_handle ) { 49 $myuid = getmyuid(); 50 $owner = @fileowner($temp_file_name); 51 @fclose($temp_handle); 52 @unlink($temp_file_name); 53 if ( $myuid == $owner ) 54 $method = 'direct'; 55 else { 56 $fs_msg = 'The owner of the scripts (most likely your FTP user) is different from the user that runs the PHP server process. </br>'; 57 $fs_msg .= 'Files handled through Edge Suite might not be manually deletable by you through FTP. <br>'; 58 $fs_msg .= 'Alternative uploading methods are on the roadmap for Edge Suite.'; 59 } 60 } 61 else{ 62 $fs_msg = 'Tmp test file could not be written to ' . EDGE_SUITE_PUBLIC_DIR; 63 } 64 } 65 else{ 66 $fs_msg = 'PHP functions getmyuid() and fileowner() could not be found.'; 67 } 68 if(!empty($fs_msg)){ 69 $msg['filesystem'] = $fs_msg; 70 } 71 72 return $msg; 73 74 } 75 76 77 function unzip($file, $to){ 78 if ( class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true ) ) { 79 80 81 require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); 82 require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'); 83 $filesystem = new WP_Filesystem_Direct(null); 84 85 $z = new ZipArchive(); 86 87 // PHP4-compat - php4 classes can't contain constants 88 $zopen = $z->open($file, /* ZIPARCHIVE::CHECKCONS */ 4); 89 if ( true !== $zopen ) 90 return new WP_Error('incompatible_archive', __('Incompatible Archive.')); 91 92 93 for ( $i = 0; $i < $z->numFiles; $i++ ) { 94 if ( ! $info = $z->statIndex($i) ) 95 return new WP_Error('stat_failed', __('Could not retrieve file from archive.')); 96 97 if ( '/' == substr($info['name'], -1) ) // directory 98 continue; 99 100 if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files 101 continue; 102 103 if(!preg_match('/(.*)\.(' . EDGE_SUITE_ALLOWED_ASSET_EXTENSIONS . ')$/', $info['name'])){ 104 continue; 105 } 106 107 $dir_creation = mkdir_recursive(trailingslashit($to) . dirname($info['name'])); 108 $contents = $z->getFromIndex($i); 109 if ( false === $contents ) 110 return new WP_Error('extract_failed', __('Could not extract file from archive.'), $info['name']); 111 112 if ( ! $filesystem->put_contents( trailingslashit($to) . $info['name'], $contents, FS_CHMOD_FILE) ) 113 return new WP_Error('copy_failed', __('Could not copy file.'), $to . $info['name']); 114 } 115 116 $z->close(); 117 118 return true; 119 120 } 121 } 3 122 4 123 function file_scan_directory($dir, $pattern) { … … 13 132 } 14 133 15 function rmdir_recursive($path) { 16 global $wp_filesystem; 17 $wp_filesystem->rmdir($path, TRUE); 134 function rmdir_recursive($dir) { 135 //global $wp_filesystem; 136 foreach(glob($dir . '/*') as $file) { 137 if(@is_dir($file)) 138 rmdir_recursive($file); 139 else 140 @unlink($file); 141 } 142 @rmdir($dir); 18 143 } 19 144 … … 28 153 29 154 function dir_is_writable($path){ 30 global $wp_filesystem; 31 return $wp_filesystem->is_writable($path); 155 //global $wp_filesystem; 156 return is_writable($path); 157 } 158 159 160 function move_file($source, $destination){ 161 // Todo: add overwrite flag 162 // Todo: copy new file, delete old file 163 return rename($source, $destination); 164 32 165 } 33 166 -
edge-suite/trunk/readme.txt
r593619 r602441 1 1 === Edge Suite === 2 2 Contributors: ti2m 3 Tags: media, animation, interactive, adobe edge , edge animate, edge, embed, integration3 Tags: media, animation, interactive, adobe edge animate, edge animate, edge, embed, integration 4 4 Requires at least: 4.3 5 5 Tested up to: 4.3 … … 17 17 Since Edge Animate itself is still in pre-release this plugin is a moving target as well and should therefore not yet be used in production. 18 18 19 There have been problems with unzipping composition archives on shared hosting plans due to the wordpress filesystem. More detailed info is available in the FAQ section. 20 21 Roadmap: FTP Filesystem support, data injection 22 19 23 Please help to review and test the plugin. Feedback is appreciated. 20 24 … … 25 29 * Easy placement of compositions on the website 26 30 31 == Frequently Asked Questions == 32 33 = PHP ZipArchive not found = 34 35 zip.so needs to be installed as a PHP library 27 36 28 37 == Installation == … … 50 59 51 60 Please report any bugs to the Edge Suite support queue on wordpress. 61 62 63 == Changelog == 64 65 = 0.2 = 66 Change of filesystem usage
Note: See TracChangeset
for help on using the changeset viewer.