MT4.x¥×¥é¥°¥¤¥óºîÀ®/PHP¥¹¥¯¥ê¥×¥È¤ÎTips http://www.ark-web.jp/sandbox/wiki/2633.html
MT4.x¥×¥é¥°¥¤¥óºîÀ®/PHP¥¹¥¯¥ê¥×¥È¤ÎTips
¡Ê¼ç¤È¤·¤Æ¡Ë¥À¥¤¥Ê¥ß¥Ã¥¯¥Ñ¥Ö¥ê¥Ã¥·¥ó¥°¤ËÂбþ¤·¤¿¥×¥é¥°¥¤¥ó¤òºîÀ®¤¹¤ë¾ì¹ç¡¢¥¨¥ó¥É¥æ¡¼¥¶¡¼¤Ë¸ø³«¤µ¤ì¤ëÀ¸À®Êª¡Ê¥¨¥ó¥È¥ê¡¼¤äWeb¥Ú¡¼¥¸¡¢¥¤¥ó¥Ç¥Ã¥¯¥¹¥Ú¡¼¥¸¤ä³Æ¥¢¡¼¥«¥¤¥Ö¡Ë¤ËÂФ·¤ÆºîÍѤ¹¤ëµ¡Ç½¤Ë´Ø¤·¤Æ¤ÏPHP¥¹¥¯¥ê¥×¥È¤ò¼ÂÁõ¤·¡¢¥À¥¤¥Ê¥ß¥Ã¥¯¥Ñ¥Ö¥ê¥Ã¥·¥ó¥°ÍøÍÑ»þ¤Ë¤Ï¤³¤ÎPHP¥¹¥¯¥ê¥×¥È¤òÆ°ºî¤µ¤»¤ë¤³¤È¤Çµ¡Ç½¤òÄ󶡤·¤Þ¤¹¡£
¤³¤Î¥Ú¡¼¥¸¤Ç¤Ï¥À¥¤¥Ê¥ß¥Ã¥¯¥Ñ¥Ö¥ê¥Ã¥·¥ó¥°Âбþ¥×¥é¥°¥¤¥óºîÀ®¤ÎPHP¤ÎTips¤ò¤Þ¤È¤á¤Æ¤¤¤¤Þ¤¹¡£¿·¤·¤¤Tips¤¬¸«¤Ä¤«¤ì¤Ð¿ï»þÄɲ䷤Ƥ¤¤¤Þ¤¹¡£
½é´ü²½½èÍý¤Ë¥Õ¥Ã¥¯¤¹¤ë †
¥À¥¤¥Ê¥ß¥Ã¥¯¥Ñ¥Ö¥ê¥Ã¥·¥ó¥°¤Ç¥Ú¡¼¥¸¤¬ÉÁ²è¤µ¤ì¤ë¤È¤¡¢¤½¤ÎÂç¤Þ¤«¤Ê¥·¡¼¥±¥ó¥¹¤Ï
¥Ö¥é¥¦¥¶¤Ç¥À¥¤¥Ê¥ß¥Ã¥¯¥Ñ¥Ö¥ê¥Ã¥·¥ó¥°¤ÇÉÁ²è¤µ¤ì¤ë¥Ú¡¼¥¸¤Ë¥¢¥¯¥»¥¹ -> Apache¤Îmod_rewrite¤Ë¤è¤Ã¤Æmtview.php¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë -> mt.php¤¬require¤µ¤ì¤ë -> (½ô¡¹¤ÎÉÁ²è½èÍý¡Ë ÉÁ²è <-
¤È¤¤¤¦·Á¤Ë¤Ê¤ê¤Þ¤¹¡£¤³¤³¤Ç¡¢mt.php¤Ïinit_plugins¥á¥½¥Ã¥É¤ÇPHP¤Çµ½Ò¤µ¤ì¤¿¥×¥é¥°¥¤¥ó¤Î¥¹¥¯¥ê¥×¥È¤òõ¤·¤Þ¤¹¡£¥×¥é¥°¥¤¥ó¤ÎPHP¥¹¥¯¥ê¥×¥È¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç
MT_DIR/plugins/[¥×¥é¥°¥¤¥ó̾]/php/
ÇÛ²¼¤Ë¸ºß¤¹¤ë¤³¤È¤ò´üÂÔ¤µ¤ì¤Þ¤¹¡£
init_plugins¥á¥½¥Ã¥É¤Ç¤Ï½ç¤Ë¸ºß¤¹¤ë¥×¥é¥°¥¤¥ó¤ÎPHP¥¹¥¯¥ê¥×¥È¤òõ¤·¤Æ¤¤¤Ã¤Æ¡¢
- init.*.php¤È¤¤¤¦Ì¾Á°¡Êinit.hoge.php¤È¤«¡Ë¤Î¥Õ¥¡¥¤¥ë¤¬¤¢¤ì¤Ðrequire_once¤¹¤ë
- modifier.*.php¤È¤¤¤¦Ì¾Á°(modifier.hoge.php¤È¤«¡Ë¤Î¥Õ¥¡¥¤¥ë¤¬¤¢¤ì¤Ðadd_global_filter¥á¥½¥Ã¥É¤ò»È¤Ã¤Æ¥Õ¥£¥ë¥¿¡¼¤È¤·¤ÆÅÐÏ¿¤¹¤ë
¤È¤¤¤Ã¤¿½èÍý¤ò¹Ô¤¤¤Þ¤¹¡£
¤Ç¤¹¤Î¤Ç¡¢¥À¥¤¥Ê¥ß¥Ã¥¯¥Ñ¥Ö¥ê¥Ã¥·¥ó¥°¤Î½é´ü²½½èÍý¤Ë¥Õ¥Ã¥¯¤·¤¿¤¤¾ì¹ç¤Ï¡¢
MT_DIR/plugins/[¥×¥é¥°¥¤¥ó̾]/php/init.*.php
¥Õ¥¡¥¤¥ë¤òÍÑ°Õ¤¹¤ë¤³¤È¤ÇÂбþ¤Ç¤¤Þ¤¹¡£
¥×¥é¥°¥¤¥ó´ÉÍý²èÌ̤ǤÎÀßÄêÃͤμèÆÀ †
MT4.x¥×¥é¥°¥¤¥óºîÀ®/¥×¥é¥°¥¤¥ó´ÉÍý²èÌ̤κîÀ®¤Ç¥×¥é¥°¥¤¥ó¤Î´ÉÍý²èÌ̤òºîÀ®¤·¡¢ÀßÄêÃͤòÄêµÁ¤¹¤ëÊýË¡¡¢¼èÆÀ¤¹¤ëÊýË¡¤ò¤½¤ì¤¾¤ì²òÀ⤷¤Æ¤¤¤Þ¤¹¡£¤³¤ÎÀßÄêÃͤòPHP¥¹¥¯¥ê¥×¥È¤«¤é¼èÆÀ¤·¤¿¤¤¾ì¹ç¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤·¤Æ¹Ô¤¤¤Þ¤¹¡£
global $mt; $pluginData = $mt->db->fetch_plugin_config('[¥×¥é¥°¥¤¥óID]'); $val = $pluginData['[¼èÆÀ¤·¤¿¤¤ÀßÄêÃͤÎkey]'];
$mt¤Ï¥×¥é¥°¥¤¥ó¤ÎPHP¥¹¥¯¥ê¥×¥ÈÆâ¤ÇÍøÍѤǤ¤ëmt.php(MT¥¯¥é¥¹)¤Î»²¾È¤ÇglobalÊÑ¿ô¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£$mt->db->fetch_plugin_config¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ç»ØÄꤷ¤¿¥×¥é¥°¥¤¥óID¤Î¥×¥é¥°¥¤¥ó¤¬»ý¤ÄÀßÄêÃͤò¥Ï¥Ã¥·¥å¤Ç¼èÆÀ¤Ç¤¤Þ¤¹¡£
Î㤨¤Ð¡¢AForm¤ÎÀßÄêÃÍscript_url_dir¤òPHP¥¹¥¯¥ê¥×¥È¤Ç¼èÆÀ¤¹¤ë¤Ë¤Ï
global $mt; $pluginData = $mt->db->fetch_plugin_config('AForm'); $script_url_dir = $pluginData['script_url_dir'];
¤Î¤è¤¦¤Ë¤·¤Þ¤¹¡£
¥»¥Ã¥·¥ç¥ó¤Î¼èÆÀ †
¥Ö¥é¥¦¥¶¤ÎCOOKIE¤Ë¥»¥Ã¥·¥ç¥óID¤¬³ÊǼ¤µ¤ì¤Æ¤¤¤ë¾õÂÖ¤ÇPHP¥¹¥¯¥ê¥×¥È¦¤Ç¤½¤Î¥»¥Ã¥·¥ç¥ó¤ò¼èÆÀ¤·¤¿¤¤¾ì¹ç¤Ï¼¡¤Î¤è¤¦¤Ë¹Ô¤¤¤Þ¤¹¡£
# ¥»¥Ã¥·¥ç¥óID¤ò¼èÆÀ $sessionId = $_COOKIE['[¥»¥Ã¥·¥ç¥óID¤¬³ÊǼ¤µ¤ì¤Æ¤¤¤ëCOOKIE¤Îname]']; if ( !empty($sessionId) ) { # ¥·¥ê¥¢¥é¥¤¥º¤µ¤ì¤¿¾õÂ֤Υ»¥Ã¥·¥ç¥óÃͤò¼èÆÀ ¡¡$sessionSerializedValue = $mt->cache_driver()->get($sessionId); ¡¡if ( !empty($sessionSerializedValue) ) { # unserialize¥á¥½¥Ã¥É¤Çunserialize¤·¤ÆÏ¢ÁÛÇÛÎó¡Ê¥Ï¥Ã¥·¥å¡Ë¤Ë¤¹¤ë ¡¡¡¡$sessionValues = $mt->db()->unserialize($sessionSerializedValue); ¡¡¡¡$val = $sessionValues['[¼èÆÀ¤·¤¿¤¤¥»¥Ã¥·¥ç¥óÃͤÎkey]']; ¡¡} }
tag: Movable Type¡¢MT¡¢MTPlugin¡¢¥À¥¤¥Ê¥ß¥Ã¥¯¥Ñ¥Ö¥ê¥Ã¥·¥ó¥°?