忍者ブログ

カウンター

プロモーション

カレンダー

03 2024/04 05
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

AntinomyMy の実験室

   私のWEBアプリ実験室です!

ブログ内検索

楽天でお買い物

twitter

最新トラックバック

最新コメント

忍者アナライズ

ウェザーニュース

バーコード

本を買う

アクセス解析

Google+

[PR]

[PR]

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。


No Image

php7.2 で確認。php_opcache はZend OPcache 、つまりextension でなくzend_extension だった。

PHP の調べ物

OPcacheは、PHP7.2 のWindows ローカルでようやく使い出したので、
それ以前は知らない。

なぜ使おうかと思ったかと言うと、
OPcache はPHP7.1からかなり早くなったらしい(余談だけど)。

php.ini

exteinsion の記述になぜか
;extension=php_opcache
という注釈化された記述がない

おかしいな?

ext フォルダに
php_opcache.dll

があるんだけど

試しに
extension=php_opcache
と記述

動かない!!!

意味が分からないのでネットで調べると
zend_extension=

"xxx\php_opcache.dll"
が読み込まれる設定の記述が

試しにやってみる
zend_extension="ext\php_opcache.dll"

動かない・・・

うん?!
コマンドラインCli の方で実行すると、どうもext にext のフォルダがない様な趣旨のエラー

もともと、extension のフォルダの中身を、見ているみたい。
バッチファイル(.bat)によってコマンドとして、php.exe を-S として
呼び出す様にして使っているので、
extension_dir = "./ext"
としてあるので、ここを
zend_extension
の設定は見ている様だ。

なんかややこしいが


zend_extension="php_opcache.dll"
としたら
なんと動いた!

後はphp.ini に非常に多くの設定があるの

[opcache]
zend_extension= "php_opcache.dll"
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=1
; The OPcache shared memory storage size.
opcache.memory_consumption=128
; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8
; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 1000000 are allowed.
opcache.max_accelerated_files=10000
; The maximum percentage of "wasted" memory until a restart is scheduled.
opcache.max_wasted_percentage=5
; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
; files with the same name (basename). Disabling the directive improves
; performance, but may break existing applications.
;opcache.use_cwd=1
; When disabled, you must reset the OPcache manually or restart the
; webserver for changes to the filesystem to take effect.
;opcache.validate_timestamps=1
; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. ("1" means validate once per second, but only
; once per request. "0" means always validate)
opcache.revalidate_freq=2
; Enables or disables file search in include_path optimization
;opcache.revalidate_path=0
; If disabled, all PHPDoc comments are dropped from the code to reduce the
; size of the optimized code.
;opcache.save_comments=1
; Allow file existence override (file_exists, etc.) performance feature.
;opcache.enable_file_override=0
; A bitmask, where each bit enables or disables the appropriate OPcache
; passes
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
; The location of the OPcache blacklist file (wildcards allowed).
; Each OPcache blacklist file is a text file that holds the names of files
; that should not be accelerated. The file format is to add each filename
; to a new line. The filename may be a full path or just a file prefix
; (i.e., /var/www/x  blacklists all the files and directories in /var/www
; that start with 'x'). Line starting with a ; are ignored (comments).
;opcache.blacklist_filename=
; Allows exclusion of large files from being cached. By default all files
; are cached.
;opcache.max_file_size=0
; Check the cache checksum each N requests.
; The default value of "0" means that the checks are disabled.
;opcache.consistency_checks=0
; How long to wait (in seconds) for a scheduled restart to begin if the cache
; is not being accessed.
;opcache.force_restart_timeout=180
; OPcache error_log file name. Empty string assumes "stderr".
;opcache.error_log=
; All OPcache errors go to the Web server log.
; By default, only fatal errors (level 0) or errors (level 1) are logged.
; You can also enable warnings (level 2), info messages (level 3) or
; debug messages (level 4).
;opcache.log_verbosity_level=1
; Preferred Shared Memory back-end. Leave empty and let the system decide.
;opcache.preferred_memory_model=
; Protect the shared memory from unexpected writing during script execution.
; Useful for internal debugging only.
;opcache.protect_memory=0
; Allows calling OPcache API functions only from PHP scripts which path is
; started from specified string. The default "" means no restriction
;opcache.restrict_api=
; Mapping base of shared memory segments (for Windows only). All the PHP
; processes have to map shared memory into the same address space. This
; directive allows to manually fix the "Unable to reattach to base address"
; errors.
;opcache.mmap_base=
; Enables and sets the second level cache directory.
; It should improve performance when SHM memory is full, at server restart or
; SHM reset. The default "" disables file based caching.
;opcache.file_cache=
; Enables or disables opcode caching in shared memory.
;opcache.file_cache_only=0
; Enables or disables checksum validation when script loaded from file cache.
;opcache.file_cache_consistency_checks=1
; Implies opcache.file_cache_only=1 for a certain process that failed to
; reattach to the shared memory (for Windows only). Explicitly enabled file
; cache is required.
;opcache.file_cache_fallback=1
; Enables or disables copying of PHP code (text segment) into HUGE PAGES.
; This should improve performance, but requires appropriate OS configuration.
;opcache.huge_code_pages=1
; Validate cached file permissions.
;opcache.validate_permission=0
; Prevent name collisions in chroot'ed environment.
;opcache.validate_root=0
こんな感じで設定したら

Zend OPcache

Opcode Caching Up and Running
Optimization Enabled
SHM Cache Enabled
File Cache Disabled
Startup OK
Shared memory model win32
Cache hits 0
Cache misses 1
Used memory 18735736
Free memory 115481992
Wasted memory 0
Interned Strings Used memory 193336
Interned Strings Free memory 8195272
Cached scripts 1
Cached keys 1
Max keys 16229
OOM restarts 0
Hash keys restarts 0
Manual restarts 0
DirectiveLocal ValueMaster Value
opcache.blacklist_filename no value no value
opcache.consistency_checks 0 0
opcache.dups_fix Off Off
opcache.enable On On
opcache.enable_cli On On
opcache.enable_file_override Off Off
opcache.error_log no value no value
opcache.file_cache no value no value
opcache.file_cache_consistency_checks 1 1
opcache.file_cache_fallback 1 1
opcache.file_cache_only 0 0
opcache.file_update_protection 2 2
opcache.force_restart_timeout 180 180
opcache.inherited_hack On On
opcache.interned_strings_buffer 8 8
opcache.log_verbosity_level 1 1
opcache.max_accelerated_files 10000 10000
opcache.max_file_size 0 0
opcache.max_wasted_percentage 5 5
opcache.memory_consumption 128 128
opcache.mmap_base no value no value
opcache.opt_debug_level 0 0
opcache.optimization_level 0x7FFFBFFF 0x7FFFBFFF
opcache.preferred_memory_model no value no value
opcache.protect_memory 0 0
opcache.restrict_api no value no value
opcache.revalidate_freq 2 2
opcache.revalidate_path Off Off
opcache.save_comments 1 1
opcache.use_cwd On On
opcache.validate_permission Off Off
opcache.validate_timestamps On On
こんな感じだった。

セオリー的な設定とかある様だが、
ネット上の検索や公式では
http://php.net/manual/ja/opcache.installation.php
以下


opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

とりあえず、PHP7.2 に
なぜかPHP5x のバージョンのphp.ini になかったOPcache項目が
注釈で書かれているし、なかった項目や、なくなった項目とかも
多分ありそうなので、見直した方がいいかなと思う。

インクルード先の話は戻るが、
dell 本体の名前を、php_zend_opcache.dll
とか、そういうリネーム(普通しない)にするか、
それともインクルード先として読みに行くext フォルダの中に
子のフォルダを適当な区別できる名前(zend とかOutside)のフォルダの中に
入れてくれるか、どっちかをしないと、zend_extensionの分類で
インクルードしていることが分かり難い。

フルパスでない場合にはextension_dir を
zend_extension は見ているとか、
説明どこかにあるのか(単純に無い?)は知らないが、直感的にはわからない



悩んでたのでメモにしたら長くなったブログでした

お粗末<_ _>

拍手[0回]

PR

No Image

PHP7 APCu の設定

PHP の調べ物


PHP info を見て、同じコンパイル方法で、
自身のPHP のバージョンのPECL のAPCu を入れる
https://pecl.php.net/package/APCu

当方の場合、Windows の64bit でPHP7.2.2 の
https://pecl.php.net/package/APCu/5.1.10/windows
7.2 Thread Safe (TS) x64
を使用した。
自身のPHPにあったものを使う

どうも、PHP5.5や5.6 だと、APC とAPCu がかぶっているらしいので、

apcu_bc というPECL を使わないといけないらしい
https://pecl.php.net/package/apcu_bc


しかし、今回、当方が使うのはPHP7系なので、apcu_bc という
apc の機能をつぶすものは入れる必要はない

入れたら
php.ini の設定だが
まず、エクステンションを読み込む。
PHP7からは、Linux でもWindows でも、
xxx.dll や、xxx.so の様に拡張子の記述の必要がなくなっている!

なので、php.ini に
extension=php_apcu
と書いて、拡張の設定をphp.ini の一番最後の方にでも、
CLi から使うならphp.ini に

apc.enable_cli=1
追加する

例えばネットでみる設定は
[apcu]
apc.enabled=1
apc.shm_size=32M
apc.ttl=7200
apc.enable_cli=1
apc.serializer=php

などであった。

当方の場合、キャッシュのサイズを自動にしたかったのだが、
自動ができるか?と思い、-1 を設定してみたが、
自動にはならず、0や-1 を設定すると、強制的に32M に戻されてしまう様だ



CLi の場合の確認は、
php.exe の該当のコマンドで
php.exe -i | grep

とすれば
~ 略 ~

apcu
APCu Support => Enabled
Version => 5.1.10
APCu Debugging => Disabled
MMAP Support => Disabled
Serialization Support => php
Build Date => Feb 16 2018 07:38:57
Directive => Local Value => Master Value
apc.coredump_unmap => Off => Off
apc.enable_cli => On => On
apc.enabled => On => On
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.preload_path => no value => no value
apc.serializer => php => php
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => On => On
apc.smart => 0 => 0
apc.ttl => 7200 => 7200
apc.use_request_time => On => On
apc.writable => /tmp => /tmp

と出てくれば成功。



そして
あとから説明をする、APCやAPCu をGUI で表示するのならば、
;extension=gd2

extension=gd2

そしてこれもはじめ悩んだが、
phpinfo() の関数でapcu の項目が、GUIのこの関数では出てこない!
output_buffering = Off

としよう、値が入っていると動かない!!!


また、最後に前途のGUI でAPC もしくはAPCu の使用量等や、
設定の項目を閲覧するツールは
PHP7 以前のものを使っていると古いのか、閲覧できなかった。

なので新しいものを
https://raw.githubusercontent.com/krakjoe/apcu/master/apc.php

からダウンロードしたら、あっさり閲覧できた。



以上、メモでした
お粗末<_ _>


大事な追伸!!!(2020年5月3日)
Windows版の拡張を使っていて気が付いたのですが、
同時にコンパイルされて(して)出来たバージョンの拡張には、
.dll を付けなくとも、phpinfo() で拡張がされたことになりますが、
どうも、後からPECL としてダウンロードしたものであると、
.dll を付けないと認識しない気がする。。。。

なので、何処かの誰かがcompileして、一式dll も入っているものでも、
良く分からないけれど、APCu ならば、.dll は必要で、
extension=php_apcu
だと動かず。。。

extension=php_apcu.dll
でないといけない気がする。。。

なんなんだ、この謎仕様は?

お粗末<_ _>

拍手[0回]


No Image

Excel BVA のパスワードの解除は凡人でも特殊なこと無しできるって言ってるのに分からない人が・・・

Excel (VBA)

マクロ(プログラム)を書かれたExcel VBA をそのまま配布しちゃおう!とてる人が居て、
とても絶句してたんだけど・・・・

理由はExcel VBA のロックの機能はお飾りでしかない
な ん の い み も な い

バカみたいなんだけど、なんか正直、マイクロソフトが酷い杜撰としか言い様がない

パスワードをずっとずっとヒットするまで入れ続けるプログラムすら要らない

以下を適当な空のテキストの拡張子をxlsm に変えて、貼るだけ

Option Explicit
Private Const PAGE_EXECUTE_READWRITE = &H40
Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Long, Source As Long, ByVal Length As Long)
Private Declare Function VirtualProtect Lib "kernel32" (lpAddress As Long, _
ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long
Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _
ByVal lpProcName As String) As Long
Private Declare Function DialogBoxParam Lib "user32" Alias "DialogBoxParamA" (ByVal hInstance As Long, _
ByVal pTemplateName As Long, ByVal hWndParent As Long, _
ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Integer
Dim HookBytes(0 To 5) As Byte
Dim OriginBytes(0 To 5) As Byte
Dim pFunc As Long
Dim Flag As Boolean
Private Function GetPtr(ByVal Value As Long) As Long
GetPtr = Value
End Function
Public Sub RecoverBytes()
If Flag Then MoveMemory ByVal pFunc, ByVal VarPtr(OriginBytes(0)), 6
End Sub
Public Function Hook() As Boolean
Dim TmpBytes(0 To 5) As Byte
Dim p As Long
Dim OriginProtect As Long
Hook = False
pFunc = GetProcAddress(GetModuleHandleA("user32.dll"), "DialogBoxParamA")
If VirtualProtect(ByVal pFunc, 6, PAGE_EXECUTE_READWRITE, OriginProtect) <> 0 Then
MoveMemory ByVal VarPtr(TmpBytes(0)), ByVal pFunc, 6
If TmpBytes(0) <> &H68 Then
MoveMemory ByVal VarPtr(OriginBytes(0)), ByVal pFunc, 6
p = GetPtr(AddressOf MyDialogBoxParam)
HookBytes(0) = &H68
MoveMemory ByVal VarPtr(HookBytes(1)), ByVal VarPtr(p), 4
HookBytes(5) = &HC3
MoveMemory ByVal pFunc, ByVal VarPtr(HookBytes(0)), 6
Flag = True
Hook = True
End If
End If
End Function
Private Function MyDialogBoxParam(ByVal hInstance As Long, _
ByVal pTemplateName As Long, ByVal hWndParent As Long, _
ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Integer
If pTemplateName = 4070 Then
MyDialogBoxParam = 1
Else
RecoverBytes
MyDialogBoxParam = DialogBoxParam(hInstance, pTemplateName, _
hWndParent, lpDialogFunc, dwInitParam)
Hook
End If
End Function


それと


Sub unprotected()
If Hook Then
MsgBox "VBA Project is unprotected!", vbInformation, "*****"
End If
End Sub



それを知らない人が多い

プログラム で労力をお金に換算できるもしくは、
それ以上になるのならば、Excel VBA で成果物を中身を閲覧できない状況下にあると
思って暗号化して売ってはいけないと思う・・・・・




http://www.saka-en.com/office/excel-vba-password-unlock/

http://hyano7.at.webry.info/201503/article_5.html


何やってるんだ!マイクロソフト


というか、そのお蔭で他の暗号化できる機構やソフトが光るけど
何とも言い難い

拍手[0回]


No Image

MySQL 同じテーブルで同じレコードを重複させて結合させる UNION ALL とSELECT に AS

PHP の調べ物

SELECT を使って、同じテーブルの内容で
レコードをかぶってる状態で取得したかった。

たとえば1回のクエリーを送るだけで、
ランキングで自身+100件とか取得出来れば楽だ(プロシージャーをCALLする等)

それではじめは、SELECT に as 適当な名前(例では t_colom)
にして、余計なカラムで順位をつけて取得するみたいなことをしていた。
(実験だから、自身のIDが下に結合されてついてます)


SELECT '1' as t_column, user_id FROM `xxx_table` LIMIT 3
UNION
SELECT '2' as t_column, user_id FROM `xxx_table`
WHERE
`user_id`='0003';
t_columnuser_id
1 0001
1 0002
1 0003
2 0003

しかし、UNION ってALL をつけると、重複してくれて、すべてを取得できる。


SELECT user_id FROM `xxx_table` LIMIT 3
UNION ALL
SELECT user_id FROM `xxx_table`
WHERE
`user_id`='0003';
 
user_id
0001
0002
0003
0003


知らなかった・・・w

UNION DISTINCT がデフォルトで、
UNION って書く場合には、DISTINCT が指定されていることになっている。
知らなかった・・・ 知らなかった・・・

はじめ覚えた本にそんな事が書かれてなかった本で
それをずっと信じていた。

いっぱいあちこち見てみるもんだなぁ・・・

拍手[0回]


No Image

MySQL で as で選択した内容をテーブルにできるんだった

MySQL の調べ物

久しぶりにSQL を触ってとても単純な事を忘れて戸惑った(ブログも超久しぶりに書いた)

SELECT a,b FROM (select 1 as a,2 as b) as x
UNION
SELECT a,b FROM (select 2 as a,3 as b) as x
UNION
SELECT a,b FROM (select 4 as a,5 as b, 6 as c, 7 as d) as x


また変な誤解で
as tables とか as table
は、別のものだと思ってた

完全に何だろう?と思っていた
table とかtables とか使っている例は
単なる一時的な命名だった・・・

as はas で、それがカラムだったり、テーブルだったり、
状況に応じて変化する様だ

バカみたいだけど、結構、単純な事を知ったつもりで
知らずに通過してきたんだなって思える時がSQLについては多い・・・

プロシージャーとかを連続で使って
LIMIT 句に変数が使えなくて、
PREPARE を使って ? に入れると出来るとか
PHP のクエリー作成時にPHP側で処理している
やたらPHPに頼ったゴリゴリ書いて動かしてたりすると
気が付かないこととか多い。

プロシージャーで書くことは
やはりとてもメリットが大きいと思えて仕方ない^w^;(勉強や速度を含めた意味で)

拍手[0回]


[PR]