Changeset 3262717
- Timestamp:
- 03/27/2025 10:12:17 AM (12 months ago)
- Location:
- dashi
- Files:
-
- 1 deleted
- 6 edited
- 8 copied
-
tags/3.1.9 (copied) (copied from dashi/trunk)
-
tags/3.1.9/classes/Posttype/Another.php (copied) (copied from dashi/trunk/classes/Posttype/Another.php)
-
tags/3.1.9/classes/Posttype/Base.php (copied) (copied from dashi/trunk/classes/Posttype/Base.php)
-
tags/3.1.9/classes/Posttype/Index.php (copied) (copied from dashi/trunk/classes/Posttype/Index.php)
-
tags/3.1.9/classes/Posttype/Posttype.php (copied) (copied from dashi/trunk/classes/Posttype/Posttype.php)
-
tags/3.1.9/classes/Posttype/PublicForm.php (modified) (6 diffs)
-
tags/3.1.9/classes/Posttype/Save.php (copied) (copied from dashi/trunk/classes/Posttype/Save.php)
-
tags/3.1.9/classes/Save.php (deleted)
-
tags/3.1.9/dashi.php (copied) (copied from dashi/trunk/dashi.php) (9 diffs)
-
tags/3.1.9/file.php (modified) (1 diff)
-
tags/3.1.9/readme.txt (copied) (copied from dashi/trunk/readme.txt) (2 diffs)
-
trunk/classes/Posttype/PublicForm.php (modified) (6 diffs)
-
trunk/dashi.php (modified) (9 diffs)
-
trunk/file.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dashi/tags/3.1.9/classes/Posttype/PublicForm.php
r2244334 r3262717 212 212 $retVal['dashi_uploaded_file'] = true; 213 213 214 $wp_filetype = wp_check_filetype_and_ext($file['tmp_name'], $file['name']); 215 if (!$wp_filetype['ext'] || !$wp_filetype['type']) { 216 $retVal['errors'][] = __('This file type is not allowed.', 'dashi'); 217 return $retVal; 218 } 219 214 220 // 拡張子 215 221 $ext = substr($file['name'], strrpos($file['name'], '.'), strlen($file['name'])); … … 282 288 283 289 // ファイル名を予測が難しいものにする 284 $name = wp_unique_filename( DASHI_TMP_UPLOAD_DIR, $ name);290 $name = wp_unique_filename( DASHI_TMP_UPLOAD_DIR, $file['name']); 285 291 286 292 $retVal['name'] = $name; … … 526 532 foreach ($each_errors as $error) 527 533 { 528 $html.= '<li><a href="#dashi_'.$k.'">'. $error.'</a></li>';534 $html.= '<li><a href="#dashi_'.$k.'">'.esc_html($error).'</a></li>'; 529 535 } 530 536 } … … 557 563 if (isset($attrs['type']) && ! in_array($attrs['type'], array('checkbox', 'radio'))) 558 564 { 559 $label = '<label for="dashi_'.$field.'">'. $label.'</label>';565 $label = '<label for="dashi_'.$field.'">'.esc_html($label).'</label>'; 560 566 } 561 567 … … 715 721 if (isset($v['private_form_only']) && $v['private_form_only'] == true) continue; 716 722 717 $html.= '<dt>'. $v['label'].'</dt>';723 $html.= '<dt>'.esc_html($v['label']).'</dt>'; 718 724 $html.= '<dd>'; 719 725 if (isset($vals->$k)) … … 762 768 else 763 769 { 764 $html.= join(', ', $vals->$k);770 $html.= join(', ', array_map('esc_html', $vals->$k)); 765 771 } 766 772 } -
dashi/tags/3.1.9/dashi.php
r3261519 r3262717 7 7 Text Domain: dashi 8 8 Domain Path: /languages/ 9 Version: 3.1. 89 Version: 3.1.9 10 10 Author URI: http://www.jidaikobo.com/ 11 11 thx: https://github.com/trentrichardson/jQuery-Timepicker-Addon/tree/master/src … … 31 31 if (defined('WP_INSTALLING') && WP_INSTALLING) 32 32 { 33 return;33 return; 34 34 } 35 35 36 36 // language 37 37 add_action( 38 'init',39 function () {40 load_plugin_textdomain(41 'dashi',42 FALSE,43 plugin_basename(__DIR__).'/languages'44 );45 }38 'init', 39 function () { 40 load_plugin_textdomain( 41 'dashi', 42 FALSE, 43 plugin_basename(__DIR__).'/languages' 44 ); 45 } 46 46 ); 47 47 … … 56 56 define('DASHI_FILE', __FILE__); 57 57 define('DASHI_DIR', __DIR__); 58 define('DASHI_TMP_UPLOAD_DIR', dirname(WP_PLUGIN_DIR).'/dashi_uploads/'); 58 59 $upload_dir = wp_upload_dir(); 60 define('DASHI_TMP_UPLOAD_DIR', trailingslashit($upload_dir['basedir']) . 'dashi_uploads/'); 59 61 60 62 // forge to init … … 72 74 // option menu 73 75 add_action( 74 'admin_menu', 75 function () 76 { 77 add_options_page( 78 __('Dashi Framework', 'dashi'), 79 __('Dashi Framework', 'dashi'), 80 'level_10', 81 'dashi_options', 82 array('\\Dashi\\Core\\Option', 'setting') 83 ); 84 }); 85 86 // dashi environmental check 87 // add_action( 88 // 'admin_menu', 89 // function () 90 // { 91 // $n = '<span id="dashi_env_chk" data-dashi-ajax-url="'.admin_url('admin-ajax.php').'"><span></span></span>'; 92 // // $n = '<span class="update-plugins count-1" id="dashi_env_chk" data-dashi-ajax-url="'.admin_url('admin-ajax.php').'"><span class="update-count"></span></span>'; 93 // add_submenu_page( 94 // 'index.php', 95 // __('Dashi Framework', 'dashi'), 96 // __('Dashi Framework', 'dashi').$n, 97 // 'level_10', 98 // 'dashi_todos', 99 // array('\\Dashi\\Core\\Option', 'setting') 100 // ); 101 // }); 102 103 // add_action( 104 // 'wp_ajax_dashi_ajax_env_check', 105 // function () 106 // { 107 // ob_start(); 108 // \Dashi\Core\Notation::ajax(); 109 // $buffer = ob_get_contents(); 110 // ob_end_clean(); 111 // wp_send_json_success($buffer); 112 // } 113 // ); 76 'admin_menu', 77 function () 78 { 79 add_options_page( 80 __('Dashi Framework', 'dashi'), 81 __('Dashi Framework', 'dashi'), 82 'manage_options', 83 'dashi_options', 84 array('\\Dashi\\Core\\Option', 'setting') 85 ); 86 }); 114 87 115 88 // activation hook 116 89 register_activation_hook( 117 DASHI_FILE,118 function ($network_wide)119 {120 $update = function ()121 {122 // update option - default on123 foreach (array_keys(\Dashi\Core\Option::getOptions()) as $v)124 {125 if ($v == 'dashi_google_map_api_key') continue;126 if ($v == 'dashi_server_accesslog_is_ok') continue;127 if ($v == 'dashi_backup_is_ok') continue;128 if ($v == 'dashi_allow_comments') continue;129 if ($v == 'dashi_allow_xmlrpc') continue;130 if ($v == 'dashi_keep_ssl_connection') continue;131 if ($v == 'dashi_specify_search_index') continue;132 if ($v == 'dashi_no_need_analytics') continue;133 if ($v == 'dashi_no_need_security_plugin') continue;134 if ($v == 'dashi_no_need_sitemap_plugin') continue;135 if ($v == 'dashi_no_need_dev_plugin') continue;136 if ($v == 'dashi_no_need_acc_plugin') continue;137 if ($v == 'dashi_do_not_heavy_dashboard_check') continue;138 if ($v == 'dashi_sitemap_page_upsidedown') continue;139 if ($v == 'dashi_do_eliminate_utf_separation') continue;140 if ($v == 'dashi_sitemap_home_string') continue;141 update_option($v, 1);142 }143 };144 145 if (is_multisite() && $network_wide)146 {147 global $wpdb;148 149 foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {150 switch_to_blog($blog_id);151 $update();152 restore_current_blog();153 }154 } else {155 $update();156 }157 }90 DASHI_FILE, 91 function ($network_wide) 92 { 93 $update = function () 94 { 95 // update option - default on 96 foreach (array_keys(\Dashi\Core\Option::getOptions()) as $v) 97 { 98 if ($v == 'dashi_google_map_api_key') continue; 99 if ($v == 'dashi_server_accesslog_is_ok') continue; 100 if ($v == 'dashi_backup_is_ok') continue; 101 if ($v == 'dashi_allow_comments') continue; 102 if ($v == 'dashi_allow_xmlrpc') continue; 103 if ($v == 'dashi_keep_ssl_connection') continue; 104 if ($v == 'dashi_specify_search_index') continue; 105 if ($v == 'dashi_no_need_analytics') continue; 106 if ($v == 'dashi_no_need_security_plugin') continue; 107 if ($v == 'dashi_no_need_sitemap_plugin') continue; 108 if ($v == 'dashi_no_need_dev_plugin') continue; 109 if ($v == 'dashi_no_need_acc_plugin') continue; 110 if ($v == 'dashi_do_not_heavy_dashboard_check') continue; 111 if ($v == 'dashi_sitemap_page_upsidedown') continue; 112 if ($v == 'dashi_do_eliminate_utf_separation') continue; 113 if ($v == 'dashi_sitemap_home_string') continue; 114 update_option($v, 1); 115 } 116 }; 117 118 if (is_multisite() && $network_wide) 119 { 120 global $wpdb; 121 122 foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) { 123 switch_to_blog($blog_id); 124 $update(); 125 restore_current_blog(); 126 } 127 } else { 128 $update(); 129 } 130 } 158 131 ); 159 132 … … 161 134 if (get_option('dashi_keep_ssl_connection')) 162 135 { 163 add_action(164 'template_redirect',165 function()166 {167 // HTTPS168 if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == "on") return;169 170 // GuzzleHttp171 if (172 isset($_SERVER['HTTP_USER_AGENT']) &&173 strpos($_SERVER['HTTP_USER_AGENT'], 'GuzzleHttp') !== false174 ) return;175 176 // redirect177 $location = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];178 wp_safe_redirect($location, '301'); //Moved Permanently179 exit;180 }181 );136 add_action( 137 'template_redirect', 138 function() 139 { 140 // HTTPS 141 if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == "on") return; 142 143 // GuzzleHttp 144 if ( 145 isset($_SERVER['HTTP_USER_AGENT']) && 146 strpos($_SERVER['HTTP_USER_AGENT'], 'GuzzleHttp') !== false 147 ) return; 148 149 // redirect 150 $location = esc_url_raw("https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 151 wp_safe_redirect($location, '301'); //Moved Permanently 152 exit; 153 } 154 ); 182 155 } 183 156 184 157 // add Shortcode - is_user_logged_in area 185 158 add_shortcode( 186 'loggedin',187 array('\\Dashi\\Core\\Shortcode', 'is_user_logged_in')159 'loggedin', 160 array('\\Dashi\\Core\\Shortcode', 'is_user_logged_in') 188 161 ); 189 162 190 163 // sticky 191 164 add_action( 192 'post_date_column_status',193 array('\\Dashi\\Core\\Posttype\\Sticky', 'column'),194 2,195 10165 'post_date_column_status', 166 array('\\Dashi\\Core\\Posttype\\Sticky', 'column'), 167 2, 168 10 196 169 ); 197 170 … … 199 172 // thx http://www.warna.info/archives/2593/ 200 173 add_filter('admin_body_class', 201 function ($admin_body_class)202 {203 global $current_user;204 if ( ! $admin_body_class ) {205 $admin_body_class .= ' ';206 }207 $admin_body_class .= 'role-' . urlencode( $current_user->roles[0] );208 return $admin_body_class;209 }174 function ($admin_body_class) 175 { 176 global $current_user; 177 if ( ! $admin_body_class ) { 178 $admin_body_class .= ' '; 179 } 180 $admin_body_class .= 'role-' . urlencode( $current_user->roles[0] ); 181 return $admin_body_class; 182 } 210 183 ); 211 184 … … 213 186 if (get_option('dashi_show_wp_version')) 214 187 { 215 add_action(216 'admin_bar_menu',217 function ($wp_admin_bar)218 {219 $title = sprintf(220 '<span class="ab-icon"></span><span class="ab-label">ver. %s</span>',221 get_bloginfo('version')222 );223 $wp_admin_bar->add_menu(array(224 'id' => 'dashi_show_wp_version',225 'meta' => array(),226 'title' => $title,227 'href' => admin_url('update-core.php')228 ));229 },230 9999231 );188 add_action( 189 'admin_bar_menu', 190 function ($wp_admin_bar) 191 { 192 $title = sprintf( 193 '<span class="ab-icon"></span><span class="ab-label">ver. %s</span>', 194 get_bloginfo('version') 195 ); 196 $wp_admin_bar->add_menu(array( 197 'id' => 'dashi_show_wp_version', 198 'meta' => array(), 199 'title' => $title, 200 'href' => admin_url('update-core.php') 201 )); 202 }, 203 9999 204 ); 232 205 } 233 206 … … 235 208 if (get_option('dashi_auto_update_core')) 236 209 { 237 add_filter('allow_major_auto_core_updates', '__return_true');210 add_filter('allow_major_auto_core_updates', '__return_true'); 238 211 } 239 212 240 213 if (get_option('dashi_auto_update_theme')) 241 214 { 242 add_filter('auto_update_theme', '__return_true');215 add_filter('auto_update_theme', '__return_true'); 243 216 } 244 217 245 218 if (get_option('dashi_auto_update_plugin')) 246 219 { 247 add_filter('auto_update_plugin', '__return_true');220 add_filter('auto_update_plugin', '__return_true'); 248 221 } 249 222 250 223 if (get_option('dashi_auto_update_language')) 251 224 { 252 add_filter('auto_update_translation', '__return_true');225 add_filter('auto_update_translation', '__return_true'); 253 226 } 254 227 … … 256 229 if (get_option('dashi_do_eliminate_control_codes')) 257 230 { 258 add_action(259 'init',260 function () {261 remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);262 }263 );264 } 231 add_action( 232 'init', 233 function () { 234 remove_action('template_redirect', 'wp_redirect_admin_locations', 1000); 235 } 236 ); 237 } -
dashi/tags/3.1.9/file.php
r1738272 r3262717 1 1 <?php 2 // too heavy... 3 // include dirname(dirname(dirname(dirname(__FILE__)))).'/wp-blog-header.php'; 4 // if ( ! is_user_logged_in()) die(); 2 // WordPress のルートパスを指定して読み込む 3 require_once dirname(__FILE__, 4) . '/wp-load.php'; 5 4 6 // tiny check 7 // $ok = false; 8 // if (isset($_COOKIE)) 9 // { 10 // foreach (array_keys($_COOKIE) as $k) 11 // { 12 // if (substr($k, 0, 20) == 'wordpress_logged_in_') 13 // { 14 // $ok = TRUE; 15 // break; 16 // } 17 // } 18 // } 5 // アップロードディレクトリのパスを取得(WordPressの /uploads/dashi_uploads/ 配下に限定) 6 $upload_dir = wp_upload_dir(); 7 $base_dir = trailingslashit($upload_dir['basedir']) . 'dashi_uploads/'; 19 8 20 $ok = true; 21 $ image_file = isset($_GET['path']) ? dirname(dirname(__DIR__)).'/dashi_uploads/'.$_GET['path'] : '';9 // ファイル名を取得(basename でパストラバーサル防止) 10 $filename = basename($_GET['path'] ?? ''); 22 11 12 // 許可拡張子をチェック 13 $allowed_ext = ['jpg', 'jpeg', 'pdf']; 14 $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); 15 if (!in_array($ext, $allowed_ext, true)) { 16 status_header(403); 17 exit('Forbidden: Invalid file type.'); 18 } 19 20 // 絶対パスを組み立てて検証 21 $filepath = realpath($base_dir . $filename); 23 22 if ( 24 $ok && 25 file_exists($image_file) && 26 in_array(substr(strtolower($image_file), -4), array('.jpg', 'jpeg', '.pdf')) 27 ) 28 { 29 $size = filesize($image_file); 30 header("Content-Length: $size"); 31 if (substr(strtolower($image_file), -3) == 'pdf') 32 { 33 header("Content-type: application/pdf"); 34 } 35 else 36 { 37 header("Content-type: image/jpeg"); 38 } 39 readfile($image_file); 23 $filepath === false || // ファイルが存在しない 24 strpos($filepath, realpath($base_dir)) !== 0 || // アップロードディレクトリ外を指している 25 !file_exists($filepath) 26 ) { 27 status_header(404); 28 exit('File not found.'); 40 29 } 41 else 42 { 43 header("HTTP/1.0 404 Not Found"); 44 die(); 45 } 30 31 // 適切な Content-Type を送信 32 $content_types = [ 33 'jpg' => 'image/jpeg', 34 'jpeg' => 'image/jpeg', 35 'pdf' => 'application/pdf', 36 ]; 37 header('Content-Type: ' . $content_types[$ext]); 38 header('Content-Length: ' . filesize($filepath)); 39 40 // ファイル出力 41 readfile($filepath); 42 exit; -
dashi/tags/3.1.9/readme.txt
r3261519 r3262717 5 5 Requires at least: 4.9.7 6 6 Tested up to: 6.7.1 7 Stable tag: 3.1. 87 Stable tag: 3.1.9 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 44 44 == Changelog == 45 45 46 = 3.1.9 = 47 fix path traversal 48 46 49 = 3.1.8 = 47 50 fix sashikae issue -
dashi/trunk/classes/Posttype/PublicForm.php
r2244334 r3262717 212 212 $retVal['dashi_uploaded_file'] = true; 213 213 214 $wp_filetype = wp_check_filetype_and_ext($file['tmp_name'], $file['name']); 215 if (!$wp_filetype['ext'] || !$wp_filetype['type']) { 216 $retVal['errors'][] = __('This file type is not allowed.', 'dashi'); 217 return $retVal; 218 } 219 214 220 // 拡張子 215 221 $ext = substr($file['name'], strrpos($file['name'], '.'), strlen($file['name'])); … … 282 288 283 289 // ファイル名を予測が難しいものにする 284 $name = wp_unique_filename( DASHI_TMP_UPLOAD_DIR, $ name);290 $name = wp_unique_filename( DASHI_TMP_UPLOAD_DIR, $file['name']); 285 291 286 292 $retVal['name'] = $name; … … 526 532 foreach ($each_errors as $error) 527 533 { 528 $html.= '<li><a href="#dashi_'.$k.'">'. $error.'</a></li>';534 $html.= '<li><a href="#dashi_'.$k.'">'.esc_html($error).'</a></li>'; 529 535 } 530 536 } … … 557 563 if (isset($attrs['type']) && ! in_array($attrs['type'], array('checkbox', 'radio'))) 558 564 { 559 $label = '<label for="dashi_'.$field.'">'. $label.'</label>';565 $label = '<label for="dashi_'.$field.'">'.esc_html($label).'</label>'; 560 566 } 561 567 … … 715 721 if (isset($v['private_form_only']) && $v['private_form_only'] == true) continue; 716 722 717 $html.= '<dt>'. $v['label'].'</dt>';723 $html.= '<dt>'.esc_html($v['label']).'</dt>'; 718 724 $html.= '<dd>'; 719 725 if (isset($vals->$k)) … … 762 768 else 763 769 { 764 $html.= join(', ', $vals->$k);770 $html.= join(', ', array_map('esc_html', $vals->$k)); 765 771 } 766 772 } -
dashi/trunk/dashi.php
r3261519 r3262717 7 7 Text Domain: dashi 8 8 Domain Path: /languages/ 9 Version: 3.1. 89 Version: 3.1.9 10 10 Author URI: http://www.jidaikobo.com/ 11 11 thx: https://github.com/trentrichardson/jQuery-Timepicker-Addon/tree/master/src … … 31 31 if (defined('WP_INSTALLING') && WP_INSTALLING) 32 32 { 33 return;33 return; 34 34 } 35 35 36 36 // language 37 37 add_action( 38 'init',39 function () {40 load_plugin_textdomain(41 'dashi',42 FALSE,43 plugin_basename(__DIR__).'/languages'44 );45 }38 'init', 39 function () { 40 load_plugin_textdomain( 41 'dashi', 42 FALSE, 43 plugin_basename(__DIR__).'/languages' 44 ); 45 } 46 46 ); 47 47 … … 56 56 define('DASHI_FILE', __FILE__); 57 57 define('DASHI_DIR', __DIR__); 58 define('DASHI_TMP_UPLOAD_DIR', dirname(WP_PLUGIN_DIR).'/dashi_uploads/'); 58 59 $upload_dir = wp_upload_dir(); 60 define('DASHI_TMP_UPLOAD_DIR', trailingslashit($upload_dir['basedir']) . 'dashi_uploads/'); 59 61 60 62 // forge to init … … 72 74 // option menu 73 75 add_action( 74 'admin_menu', 75 function () 76 { 77 add_options_page( 78 __('Dashi Framework', 'dashi'), 79 __('Dashi Framework', 'dashi'), 80 'level_10', 81 'dashi_options', 82 array('\\Dashi\\Core\\Option', 'setting') 83 ); 84 }); 85 86 // dashi environmental check 87 // add_action( 88 // 'admin_menu', 89 // function () 90 // { 91 // $n = '<span id="dashi_env_chk" data-dashi-ajax-url="'.admin_url('admin-ajax.php').'"><span></span></span>'; 92 // // $n = '<span class="update-plugins count-1" id="dashi_env_chk" data-dashi-ajax-url="'.admin_url('admin-ajax.php').'"><span class="update-count"></span></span>'; 93 // add_submenu_page( 94 // 'index.php', 95 // __('Dashi Framework', 'dashi'), 96 // __('Dashi Framework', 'dashi').$n, 97 // 'level_10', 98 // 'dashi_todos', 99 // array('\\Dashi\\Core\\Option', 'setting') 100 // ); 101 // }); 102 103 // add_action( 104 // 'wp_ajax_dashi_ajax_env_check', 105 // function () 106 // { 107 // ob_start(); 108 // \Dashi\Core\Notation::ajax(); 109 // $buffer = ob_get_contents(); 110 // ob_end_clean(); 111 // wp_send_json_success($buffer); 112 // } 113 // ); 76 'admin_menu', 77 function () 78 { 79 add_options_page( 80 __('Dashi Framework', 'dashi'), 81 __('Dashi Framework', 'dashi'), 82 'manage_options', 83 'dashi_options', 84 array('\\Dashi\\Core\\Option', 'setting') 85 ); 86 }); 114 87 115 88 // activation hook 116 89 register_activation_hook( 117 DASHI_FILE,118 function ($network_wide)119 {120 $update = function ()121 {122 // update option - default on123 foreach (array_keys(\Dashi\Core\Option::getOptions()) as $v)124 {125 if ($v == 'dashi_google_map_api_key') continue;126 if ($v == 'dashi_server_accesslog_is_ok') continue;127 if ($v == 'dashi_backup_is_ok') continue;128 if ($v == 'dashi_allow_comments') continue;129 if ($v == 'dashi_allow_xmlrpc') continue;130 if ($v == 'dashi_keep_ssl_connection') continue;131 if ($v == 'dashi_specify_search_index') continue;132 if ($v == 'dashi_no_need_analytics') continue;133 if ($v == 'dashi_no_need_security_plugin') continue;134 if ($v == 'dashi_no_need_sitemap_plugin') continue;135 if ($v == 'dashi_no_need_dev_plugin') continue;136 if ($v == 'dashi_no_need_acc_plugin') continue;137 if ($v == 'dashi_do_not_heavy_dashboard_check') continue;138 if ($v == 'dashi_sitemap_page_upsidedown') continue;139 if ($v == 'dashi_do_eliminate_utf_separation') continue;140 if ($v == 'dashi_sitemap_home_string') continue;141 update_option($v, 1);142 }143 };144 145 if (is_multisite() && $network_wide)146 {147 global $wpdb;148 149 foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) {150 switch_to_blog($blog_id);151 $update();152 restore_current_blog();153 }154 } else {155 $update();156 }157 }90 DASHI_FILE, 91 function ($network_wide) 92 { 93 $update = function () 94 { 95 // update option - default on 96 foreach (array_keys(\Dashi\Core\Option::getOptions()) as $v) 97 { 98 if ($v == 'dashi_google_map_api_key') continue; 99 if ($v == 'dashi_server_accesslog_is_ok') continue; 100 if ($v == 'dashi_backup_is_ok') continue; 101 if ($v == 'dashi_allow_comments') continue; 102 if ($v == 'dashi_allow_xmlrpc') continue; 103 if ($v == 'dashi_keep_ssl_connection') continue; 104 if ($v == 'dashi_specify_search_index') continue; 105 if ($v == 'dashi_no_need_analytics') continue; 106 if ($v == 'dashi_no_need_security_plugin') continue; 107 if ($v == 'dashi_no_need_sitemap_plugin') continue; 108 if ($v == 'dashi_no_need_dev_plugin') continue; 109 if ($v == 'dashi_no_need_acc_plugin') continue; 110 if ($v == 'dashi_do_not_heavy_dashboard_check') continue; 111 if ($v == 'dashi_sitemap_page_upsidedown') continue; 112 if ($v == 'dashi_do_eliminate_utf_separation') continue; 113 if ($v == 'dashi_sitemap_home_string') continue; 114 update_option($v, 1); 115 } 116 }; 117 118 if (is_multisite() && $network_wide) 119 { 120 global $wpdb; 121 122 foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs") as $blog_id) { 123 switch_to_blog($blog_id); 124 $update(); 125 restore_current_blog(); 126 } 127 } else { 128 $update(); 129 } 130 } 158 131 ); 159 132 … … 161 134 if (get_option('dashi_keep_ssl_connection')) 162 135 { 163 add_action(164 'template_redirect',165 function()166 {167 // HTTPS168 if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == "on") return;169 170 // GuzzleHttp171 if (172 isset($_SERVER['HTTP_USER_AGENT']) &&173 strpos($_SERVER['HTTP_USER_AGENT'], 'GuzzleHttp') !== false174 ) return;175 176 // redirect177 $location = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];178 wp_safe_redirect($location, '301'); //Moved Permanently179 exit;180 }181 );136 add_action( 137 'template_redirect', 138 function() 139 { 140 // HTTPS 141 if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == "on") return; 142 143 // GuzzleHttp 144 if ( 145 isset($_SERVER['HTTP_USER_AGENT']) && 146 strpos($_SERVER['HTTP_USER_AGENT'], 'GuzzleHttp') !== false 147 ) return; 148 149 // redirect 150 $location = esc_url_raw("https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 151 wp_safe_redirect($location, '301'); //Moved Permanently 152 exit; 153 } 154 ); 182 155 } 183 156 184 157 // add Shortcode - is_user_logged_in area 185 158 add_shortcode( 186 'loggedin',187 array('\\Dashi\\Core\\Shortcode', 'is_user_logged_in')159 'loggedin', 160 array('\\Dashi\\Core\\Shortcode', 'is_user_logged_in') 188 161 ); 189 162 190 163 // sticky 191 164 add_action( 192 'post_date_column_status',193 array('\\Dashi\\Core\\Posttype\\Sticky', 'column'),194 2,195 10165 'post_date_column_status', 166 array('\\Dashi\\Core\\Posttype\\Sticky', 'column'), 167 2, 168 10 196 169 ); 197 170 … … 199 172 // thx http://www.warna.info/archives/2593/ 200 173 add_filter('admin_body_class', 201 function ($admin_body_class)202 {203 global $current_user;204 if ( ! $admin_body_class ) {205 $admin_body_class .= ' ';206 }207 $admin_body_class .= 'role-' . urlencode( $current_user->roles[0] );208 return $admin_body_class;209 }174 function ($admin_body_class) 175 { 176 global $current_user; 177 if ( ! $admin_body_class ) { 178 $admin_body_class .= ' '; 179 } 180 $admin_body_class .= 'role-' . urlencode( $current_user->roles[0] ); 181 return $admin_body_class; 182 } 210 183 ); 211 184 … … 213 186 if (get_option('dashi_show_wp_version')) 214 187 { 215 add_action(216 'admin_bar_menu',217 function ($wp_admin_bar)218 {219 $title = sprintf(220 '<span class="ab-icon"></span><span class="ab-label">ver. %s</span>',221 get_bloginfo('version')222 );223 $wp_admin_bar->add_menu(array(224 'id' => 'dashi_show_wp_version',225 'meta' => array(),226 'title' => $title,227 'href' => admin_url('update-core.php')228 ));229 },230 9999231 );188 add_action( 189 'admin_bar_menu', 190 function ($wp_admin_bar) 191 { 192 $title = sprintf( 193 '<span class="ab-icon"></span><span class="ab-label">ver. %s</span>', 194 get_bloginfo('version') 195 ); 196 $wp_admin_bar->add_menu(array( 197 'id' => 'dashi_show_wp_version', 198 'meta' => array(), 199 'title' => $title, 200 'href' => admin_url('update-core.php') 201 )); 202 }, 203 9999 204 ); 232 205 } 233 206 … … 235 208 if (get_option('dashi_auto_update_core')) 236 209 { 237 add_filter('allow_major_auto_core_updates', '__return_true');210 add_filter('allow_major_auto_core_updates', '__return_true'); 238 211 } 239 212 240 213 if (get_option('dashi_auto_update_theme')) 241 214 { 242 add_filter('auto_update_theme', '__return_true');215 add_filter('auto_update_theme', '__return_true'); 243 216 } 244 217 245 218 if (get_option('dashi_auto_update_plugin')) 246 219 { 247 add_filter('auto_update_plugin', '__return_true');220 add_filter('auto_update_plugin', '__return_true'); 248 221 } 249 222 250 223 if (get_option('dashi_auto_update_language')) 251 224 { 252 add_filter('auto_update_translation', '__return_true');225 add_filter('auto_update_translation', '__return_true'); 253 226 } 254 227 … … 256 229 if (get_option('dashi_do_eliminate_control_codes')) 257 230 { 258 add_action(259 'init',260 function () {261 remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);262 }263 );264 } 231 add_action( 232 'init', 233 function () { 234 remove_action('template_redirect', 'wp_redirect_admin_locations', 1000); 235 } 236 ); 237 } -
dashi/trunk/file.php
r1738272 r3262717 1 1 <?php 2 // too heavy... 3 // include dirname(dirname(dirname(dirname(__FILE__)))).'/wp-blog-header.php'; 4 // if ( ! is_user_logged_in()) die(); 2 // WordPress のルートパスを指定して読み込む 3 require_once dirname(__FILE__, 4) . '/wp-load.php'; 5 4 6 // tiny check 7 // $ok = false; 8 // if (isset($_COOKIE)) 9 // { 10 // foreach (array_keys($_COOKIE) as $k) 11 // { 12 // if (substr($k, 0, 20) == 'wordpress_logged_in_') 13 // { 14 // $ok = TRUE; 15 // break; 16 // } 17 // } 18 // } 5 // アップロードディレクトリのパスを取得(WordPressの /uploads/dashi_uploads/ 配下に限定) 6 $upload_dir = wp_upload_dir(); 7 $base_dir = trailingslashit($upload_dir['basedir']) . 'dashi_uploads/'; 19 8 20 $ok = true; 21 $ image_file = isset($_GET['path']) ? dirname(dirname(__DIR__)).'/dashi_uploads/'.$_GET['path'] : '';9 // ファイル名を取得(basename でパストラバーサル防止) 10 $filename = basename($_GET['path'] ?? ''); 22 11 12 // 許可拡張子をチェック 13 $allowed_ext = ['jpg', 'jpeg', 'pdf']; 14 $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); 15 if (!in_array($ext, $allowed_ext, true)) { 16 status_header(403); 17 exit('Forbidden: Invalid file type.'); 18 } 19 20 // 絶対パスを組み立てて検証 21 $filepath = realpath($base_dir . $filename); 23 22 if ( 24 $ok && 25 file_exists($image_file) && 26 in_array(substr(strtolower($image_file), -4), array('.jpg', 'jpeg', '.pdf')) 27 ) 28 { 29 $size = filesize($image_file); 30 header("Content-Length: $size"); 31 if (substr(strtolower($image_file), -3) == 'pdf') 32 { 33 header("Content-type: application/pdf"); 34 } 35 else 36 { 37 header("Content-type: image/jpeg"); 38 } 39 readfile($image_file); 23 $filepath === false || // ファイルが存在しない 24 strpos($filepath, realpath($base_dir)) !== 0 || // アップロードディレクトリ外を指している 25 !file_exists($filepath) 26 ) { 27 status_header(404); 28 exit('File not found.'); 40 29 } 41 else 42 { 43 header("HTTP/1.0 404 Not Found"); 44 die(); 45 } 30 31 // 適切な Content-Type を送信 32 $content_types = [ 33 'jpg' => 'image/jpeg', 34 'jpeg' => 'image/jpeg', 35 'pdf' => 'application/pdf', 36 ]; 37 header('Content-Type: ' . $content_types[$ext]); 38 header('Content-Length: ' . filesize($filepath)); 39 40 // ファイル出力 41 readfile($filepath); 42 exit; -
dashi/trunk/readme.txt
r3261519 r3262717 5 5 Requires at least: 4.9.7 6 6 Tested up to: 6.7.1 7 Stable tag: 3.1. 87 Stable tag: 3.1.9 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 44 44 == Changelog == 45 45 46 = 3.1.9 = 47 fix path traversal 48 46 49 = 3.1.8 = 47 50 fix sashikae issue
Note: See TracChangeset
for help on using the changeset viewer.