• Как решить проблему с POST запросом по SSL протоколу?

    Track77
    @Track77 Автор вопроса
    Проблема "сам по себе" исчезла через пару дней.
    Возможно хостер что-то подправил или проблема с провайдером была - это объясняет почему мои разные компы выдавали одну ошибку и была только одна жалоба от клиента.
    Так или иначе всем спасибо.
    Ответ написан
    Комментировать
  • Как решить проблему с POST/GET запросами использущими кавычки?

    Track77
    @Track77 Автор вопроса
    Похоже что ошибка таки на стороне отправителя была.
    Сегодня заработало.

    Так или иначе всем спасибо.
    Ответ написан
    Комментировать
  • Что изменится при установке ssl сертификата?

    Думаю пригодится
    Если вы делаете перенаправление на https сервер, то данные, переданные через POST запрос удаляются
    Чтобы этого не происходило добавьте перед перенаправление строку
    RewriteCond %{REQUEST_METHOD} !=POST
    То есть при наличии POST запроса не будет перенаправления, но и данные не потеряются.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    # запретить перенаправление при запросе post
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>
    Ответ написан
    Комментировать
  • Почему в Php 7 не работает htmlspecialchars(SID)?

    Track77
    @Track77 Автор вопроса
    Будь оно неладно - ошибка была как раз в версии 5,6
    SID (string)
    Константа, содержащая либо имя сессии и идентификатор в виде "name=ID" либо пустую строку, если идентификатор сессии был установлен в соответствующие куки.


    В php.ini в обоих версиях стоят настройки:
    session.use_cookies	On	On
    session.use_only_cookies	On	On


    То есть это в версии 5,6 не должно было работать.
    Так или иначе всем спасибо.
    Ответ написан
    Комментировать
  • Есть ли такой плагин для wordpress для sharing?

    Track77
    @Track77 Автор вопроса
    Вот удобный бесплатный сервис uptolike.com
    Ответ написан
    Комментировать
  • Как отловить ошибку в плагине Wordpress?

    Track77
    @Track77 Автор вопроса
    Проблему удалось найти с помощью такого кода:
    function error_handler($code, $message, $file, $line) {
       if(! preg_match('/kses_init/',$message ))
            return;	   
       $log =  'Into '.__FUNCTION__.'() at line '.__LINE__.
       "\n\n---CODE---\n". print_r( $code, true).
       "\n\n---MESSAGE---\n". print_r( $message, true).
       "\n\n---FILE---\n". print_r( $file, true).
       "\n\n---LINE---\n". print_r( $line, true).
    	"\n\n---_SERVER---\n".  print_r($_SERVER, true). 
    	"\n\n---_POST---\n".  print_r($_POST, true)."\n\n";
        error_log(USER_IP . $log , 3, __DIR__."/test.log");
    }
    set_error_handler("error_handler");
    Ответ написан
    Комментировать
  • Как определить, что нажат Enter в ToolStripTextBox с AutoCompleteSource?

    Track77
    @Track77 Автор вопроса
    Решил таким костылем

    private bool _isKeyDown;
    
            void explorer_text_filter_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode != Keys.Enter)
                    _isKeyDown = true;
            }
    
            void explorer_text_filter_KeyUp(object sender, KeyEventArgs e)
            {
                if (!_isKeyDown && e.KeyCode == Keys.Enter && !search_button.Checked)
                {
                    search_button.PerformClick();
                }
                _isKeyDown = false;
            }
            void explorer_text_filter_TextChanged(object sender, EventArgs e)
            {
                this.explorer_text_filter.KeyUp -= explorer_text_filter_KeyUp;
                .....
                _isKeyDown = true;
                this.explorer_text_filter.KeyUp += explorer_text_filter_KeyUp;
            }
    Ответ написан
    Комментировать
  • Какая ошибка в этом SQL запросе?

    Track77
    @Track77 Автор вопроса
    Всем спасибо.
    Таки проблема оказалась то ли в превышении лимита памяти, то ли еще каких ограничениях хостера .
    Решилось заменой второго JOIN на SELECT.
    Ответ написан
    Комментировать
  • Как настроить разные описания для каждого из вариантов вариативного товара (WooCommerce)?

    Надеюсь дальше разберетесь
    Кусок из рабочего кода. Удалил несущественные фрагменты.

    <?php
    /* Add a custom field to a product variation */
    //Display Fields
    add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
    //JS to add fields for new variations
    add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );
    //Save variation fields
    add_action( 'woocommerce_process_product_meta_variable', 'variable_fields_process', 10, 1 );
    
    add_action( 'woocommerce_process_product_meta', 'variable_fields_override_price', 5, 2 );
    
    function variable_fields( $loop, $variation_data ) {
    ?>	
    <tr>
    	<td>
    		<div>
    				<label>Variable description</label>
    				<textarea type="text" size="5" name="variable_custom_description[<?php echo $loop; ?>]" ><?php echo $variation_data['_variable_custom_description'][0]; ?></textarea>
    		</div>
    	</td>
    	<td>
    		<div>
    				<label>Percent discount</label>
    				<input type="text" size="5" name="variable_percent_discount[<?php echo $loop; ?>]" value="<?php echo $variation_data['_variable_percent_discount'][0]; ?>" />
    		</div>
    	</td>
    </tr>
    <?php
    }
    
    function variable_fields_js() {
    ?>
    <tr>
    	<td>
    		<div>
    				<label>Variable description</label>
    				<textarea type="text" size="5" name="variable_custom_description[' + loop + ']" ></textarea>
    		</div>
    	</td>
    	<td>
    		<div>
    				<label>Percent discount</label>
    				<input type="text" size="5" name="variable_percent_discount[' + loop + ']" />
    		</div>
    	</td>
    </tr>
    <?php
    }
    
    /* 
    	Обновляю запрос $_POST перед записью variable
    */
    function variable_fields_override_price( $post_id, $__post ) {
    
    	if (isset( $_POST['variable_sku'] ) ) {
    		$variable_percent_discount = $_POST['variable_percent_discount'];
    		
    		if(! $variable_percent_discount )
    			return;
    			
    		$variable_post_ids = join(',', $_POST['variable_post_id']);
    		$variable_sku = $_POST['variable_sku'];
    		global $wpdb;
    		
    		foreach( $_POST['variable_post_id'] as $key => $variable ) {
    			if ( !isset( $variable_sku[$key] ))
    				continue;
    			$_sku = explode(',', $variable_sku[$key] );
    			if( count( $_sku ) == 0 )
    				continue;
    				
    			if( count($_sku) == 1 ) {
    				/*  */
    			}
    			
    			$query = "SELECT wpdb_prefix_postmeta.post_id , wpdb_prefix_posts.menu_order
    						FROM wpdb_prefix_postmeta , wpdb_prefix_posts
    						INNER JOIN wpdb_prefix_postmeta as p1 ON p1.meta_value IN(" . $variable_sku[$key] . ") 
    						WHERE wpdb_prefix_postmeta.meta_key LIKE '_sku_%' 
    						AND wpdb_prefix_postmeta.post_id=p1.post_id
    						AND wpdb_prefix_posts.ID=p1.post_id 
    						AND NOT wpdb_prefix_postmeta.post_id IN( $variable_post_ids )
    						GROUP BY wpdb_prefix_postmeta.post_id
    						ORDER BY wpdb_prefix_posts.menu_order ";
    						
    			$posts = $wpdb->get_results($query);
    			if( !$posts )
    				continue;
    			$variable_price = 0;
    			$current_price = 0;
    			$description = '';
    			foreach( $posts as $post ) {
    				$product = wc_get_product($post->post_id);
    				if(! $product)
    					continue;
    					
    				$_regular_price = get_post_meta($post->post_id, '_regular_price', true );
    				$price = $product->get_price(); // со скидкой, если она есть
    				// $price = $_regular_price;
    				
    				$current_price += $price;
    				
    				$variable_price += $_regular_price;	
    
    				$link	= get_permalink($post->post_id);	//$post->post_name;
    				$title	= get_the_title($post->post_id);										
    				$output = '<li>';
    				$output .= '<a href="' . $link . '" title="'. $title .'">'. $title .'</a><span style="float:right;"> ';
    				$output .= wc_price($_regular_price);
    				$output .= '</span></li>';
    				$description .= $output;
    			}
    
    			if( $variable_price && $current_price) {
    				$_POST['variable_regular_price'][$key] = $variable_price;
    				$_POST['variable_sale_price'][$key] = $current_price * ((100-$variable_percent_discount[$key])/100);
    			}
    			if( $description ) {
    				$description = "Products in bundle:<ul>$description</ul>";
    				$description .= "<hr style='margin:5px;'>";
    				$description .= "Normal price: " . wc_price($variable_price);
    				$description .= '<span class="price"><ins style="float:right;font-size:small;">Current price: ' . wc_price($_POST['variable_sale_price'][$key]) . '</ins></span>';
    				$_POST['variable_custom_description'][$key] = $description;
    			}
    		}
    	}
    }
    
    /* 
    	Save variation fields
    */
    function variable_fields_process( $post_id ) {
    	if (isset( $_POST['variable_sku'] ) ) :
    		$variable_sku = $_POST['variable_sku'];
    
    		$variable_post_id = $_POST['variable_post_id'];
    		$variable_custom_field = $_POST['variable_custom_description'];
    		$variable_discount_perc = $_POST['variable_percent_discount'];
    		
    		$max_loop = max( array_keys( $_POST['variable_post_id'] ) ); 
    
    		for ( $i = 0; $i <= $max_loop; $i++ ) :
    				if ( ! isset( $variable_post_id[ $i ] ) )
    					continue;
    				$variation_id = absint( $variable_post_id[ $i ] );
    				
    			if ( !isset( $variable_discount_perc[$i] ) ) 
    				$variable_discount_perc[$i] = '';				
    			if ( !isset( $variable_custom_field[$i] ) ) 
    				$variable_custom_field[$i] = '';
    			update_post_meta( $variation_id, '_variable_custom_description', stripslashes( $variable_custom_field[$i] ) );
    			update_post_meta( $variation_id, '_variable_percent_discount', stripslashes( $variable_discount_perc[$i] ) );
    
    		endfor;
    	endif;
    }
    
    /* add the custom variation meta data to the fronted */
    add_filter( 'woocommerce_available_variation', 'uniquename_available_variation', 100, 3 );
    function uniquename_available_variation($variations, $variation_object, $variation) {
        $variations['custom_field_value'] = get_post_meta($variations["variation_id"], '_variable_custom_description', true);
        return $variations;
    }
    /* Front end */
    add_action('woocommerce_single_product_summary', 'add_variation_data', 60);
    function add_variation_data() {
    	echo '<div class="selected-variation-custom-field" style="padding-top: 25px;"></div>';
    }
    
    add_action('woocommerce_after_add_to_cart_form', 'add_variation_data_script', 60);
    
    function add_variation_data_script() {
    global $product;
    if( $product && $product->product_type == "variable") {
    
     ?>
    <script>
    jQuery(function($) {
            variations_data = JSON.parse( $('form.variations_form').first().attr( 'data-product_variations' ) ),
            $selected_variation_custom_field = $('.selected-variation-custom-field'); // see DIV above
    
        $('table.variations').on('change', 'select', function() {
            var $select = $(this),
                attribute_name = $select.attr('name'),
                selected_value = $select.val(),
                custom_field_value = "";
    
            // Loop over the variations_data until we find a matching attribute value
            $.each(variations_data, function() {
                if( this.attributes[ attribute_name ] &&  this.attributes[ attribute_name ] === selected_value ) {
                    custom_field_value = variations_data[ $select[0].selectedIndex-1].custom_field_value;
                    return false; // break
                }
            });
    
            // doing this outside the loop above ensures that the DIV gets emptied out when it should
            // $selected_variation_custom_field.text( custom_field_value );
            $selected_variation_custom_field.html( custom_field_value );
        });
    });
    </script>
    	<?php
    	}
    }
    Ответ написан
    Комментировать
  • Почему приведение int к int Enum ведет себя по разному на разных компах?

    Track77
    @Track77 Автор вопроса
    В общем баг оказался в прокладке между клавиатурой и креслом - ошибся со входными данными.
    Не то тестировал - у меня работает так же и никакой мистики.
    Ответ написан
    Комментировать
  • Преобразование TreeView в ContextMenu, С#, как?

    Используйте ToolStripControlHost для добавления в меню полноценного TreeView.
    Ответ написан
    Комментировать
  • Почему перестают работать хоткеи и как исправить?

    Track77
    @Track77 Автор вопроса
    Пока что решил подобным костылем
    public class ToolStripSplitButtonEx : ToolStripSplitButton
        {
            protected override void OnDropDownClosed(EventArgs e)
            {
                base.OnDropDownClosed(e);
                if (DropDown != null)
                    DropDown.Close();
            }
        }
    Ответ написан
    Комментировать
  • Что натворил Google? Как вернуть старый интерфейс?

    На странице поиска выключите использование скриптов.
    e39e3570455d4b1384e00df4c97c2530.jpg
    Ответ написан
    Комментировать