ホーム » メモ (ページ 15)

メモ」カテゴリーアーカイブ

2025年2月
 1
2345678
9101112131415
16171819202122
232425262728  

カテゴリー

アーカイブ

ブログ統計情報

  • 106,228 アクセス


IIS+PHP

先週まで DS115j 上の PHP と exe環境を作っていたが,今度は IIS 上の PHP .
次の所を参考にさせてもらった.
 Windows 8/7/Vista に PHP をインストール
 IIS での PHP Web サイトの構成
以前の Win7 に IIS を入れた環境に設定.


PHP がうまく動作しているかの確認は,
 コマンドプロンプトで,php -v や php -r “phpinfo() ;” .

 次の内容を php として保存し,ブラウザで開く.
  <?php phpinfo(); ?>


DS115j 上で動かしたものと同等の日時の表示は,何とか動作する様になった.
ほとんどが C++ のコードなので,今回の範囲ではあまり変更はなかった.
ただ exe を呼出す PHP のパスの指定や %TMP% にあたる部分がいろいろとありそう.
パス区切りは,’/’,’\’,’\\’ などで動作するみたいだが完全なのは ‘\\’ か?
ハードコードの部分は ‘/’ として PHP_OS により ‘\\’ に変換する関数を用意する.
 コードは次の様なもの.
   function Path_Normalize ($path_) {
     $path = $path_ ;
     if (PHP_OS == ‘WINNT’) {
       $path = str_replace (“/”,DIRECTORY_SEPARATOR,$path) ;
       }
     return $path ;
     }


単に,str_replace で良さそう.
  $path = str_replace (“/”,DIRECTORY_SEPARATOR,$path) ;
c の関数マクロの様な使い方はわからなかったので,change_sp($path) の関数とした.
さらに,php ファイルのインクルードは次の様な感じで振り分け.
   if (PHP_OS == ‘WINNT’) {
     include (“./lib.php”) ;
     }
   else {
     include (“/…/i_lib/2017.06/lib.php”) ;
     }


用途によっては,realpath でもいける?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

文字列の連結

C++ tstring  strS = str1 + str2 ;
CString strM = str3 + str4 ;
JavaScript var str = str1 + str2 ;
VBScript Dim str As String
str = str1 & str2
PHP $str = $str1 . $str2 ;
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

php post , get の全ての引数を取得

$_REQUEST , $_GET など.

function  get_request_str () {
  $req ;
  foreach ($_REQUEST as $key => $value) {
   $req = $req . "$key=$value" . " " ;
   }
  return $req ;
  }
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Web + exe

最終的に目指したい所は,
IIS+PHP 環境で exe を呼び出し
参考にさせてもらったのは,
第3回 極めてシンプルなCGIを体験する.


C:\...\Iwao>"C:\...\testCGI2\DmpSVG.exe"
Content-Type: text/html
 
<?xml version="1.0" encoding="UTF-8"?>
<svg  xmlns="http://www.w3.org/2000/svg"  >
    <rect x="15" y="10" width="70" height="40" stroke="blue" fill="white" />
    </svg>
 
C:\...\Iwao>

mac で,
先ず,php から ls の呼び出し.
exec_ls.php

 <?php
  system('ls') ;

ターミナルで実行(php exec_ls.php)すると,
ターミナルで php exec_ls.php
php から a.out の呼び出し.
main.cpp

 #include <iostream>
 int main() {
  	std::cout  <<  "hello c++ php"  <<  std::endl ;
  	return 0 ;
  	}

g++ main.cpp としてコンパイル.
exec.php
 <?php
  system('./a.out') ;

ターミナルで php から a.out の呼び出し
ターミナルから php -S 127.0.0.1:8000 などとしておくと,
php から a.out の呼び出し


DS115j で,
php から ls の呼び出しまでは同様.
Iwao@DS115j:~/www/T_php/temp/test$
Iwao@DS115j:~/www/T_php/temp/test$ ls
exec_ls.php index.php main.cpp
Iwao@DS115j:~/www/T_php/temp/test$
Iwao@DS115j:~/www/T_php/temp/test$ php exec_ls.php
exec_ls.php
index.php
main.cpp
Iwao@DS115j:~/www/T_php/temp/test$
Iwao@DS115j:~/www/T_php/temp/test$

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

PHP が動かなくなっている

Synology のパーソナルウェブサイトで PHP が動かなくなった?

先日までは動作していたと思う.
アップデートで設定が変わってしまったのか?


2017/05/10
DSM と Web Station のアップデートがあったので更新したら直った?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Synology NAS で CGI

今度は,CGI.
以前少しやってみたが,500 Internal Server Error となりそのままとなっていた.


cgi の先頭行の指定が怪しいと察しはついていたので検索すると,
通常は「#!/usr/bin/perl」か「#!/usr/local/bin/perl」とのこと.
それぞれのフォルダを見ると,
Iwao@DS115j:/usr/bin$
Iwao@DS115j:/usr/bin$ ls pe*
perl perror
Iwao@DS115j:/usr/bin$
Iwao@DS115j:/usr/bin$ cd /usr/local/bin/
Iwao@DS115j:/usr/local/bin$
Iwao@DS115j:/usr/local/bin$ ls pe*
perl perl5.24.0 perlbug perldoc perlivp perlthanks
Iwao@DS115j:/usr/local/bin$


さらに検索すると,改行の問題とのこと.
「#!/usr/bin/perl –」の様に後ろに “–” を付ければ良いらしい.
または,’LF’ にすれば良いみたい.
‘CR’ として試すと,”–” の有無に関係なく 502 Bad Gateway となってしまう.
また文字コードは,UTF-8 などを使用すると思うが,「BOM なし」の必要がある.


2021/01/03
SVG を出力するコード.

#!/usr/bin/perl --

print	"Content-type: text/html\n";
print	"\n";
print	"<!DOCTYPE html>\n";
print	"<html>\n";
print	"<head>\n";
print	"	<meta charset=\"utf-8\">\n";
print	"	<title>SVG</title>\n";
print	"	</head>\n";
print	"<body>\n";
print	"	<svg  viewBox=\"0 0 100 100 \"  xmlns=\"http://www.w3.org/2000/svg\" >\n";
print	"		<rect x=\"15\" y=\"10\" width=\"70\" height=\"40\" stroke=\"blue\" fill=\"white\" />\n";
print	"		</svg>\n";
print	"	</body>\n";
print	"</html>\n";

cgi draw_rect svg
/i_Tools/…/cgi/drawrect.cgi


更に cpp として書いたコード.
g++ drawrect.cpp として出来上がった a.out を rect_cpp.cgi としてコピー.
drawrect.cpp
/i_Tools/…/cgi/rect_cpp.cgi


https://jml.mish.work/index.php/various/nas/synology-nas.html

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

現在の時刻を文字列に

C++
 time_t tim_v = ::time(NULL) ;
 struct stm = ::localtime(&tim_v) ;
 tstring buff ;
 size_t size = 255 ;
 buff.resize(size+1,0) ;
 ::_tcsftime(&buff[0],size,_T(“%Y/%m/%d %H:%M:%S”),&stm) ;
 tstring str = buff.c_str() ;

MFC
 CString str = CTime::GetCurrentTime().Format(_T(“%Y/%m/%d %H:%M:%S”)) ;

JavaScript
 var time = new Date() ;
 var y_ = time.getFullYear() ;
 var m_ = time.getMonth() + 1 ;
 var d_ = time.getDate() ;
 var hh = time.getHours() ;
 var mm = time.getMinutes() ;
 var ss = time.getSeconds() ;
 var str= (y_+”/”+m_+”/”+d_+” “+hh+”:”+mm+”:”+ss) ;

PHP
 date_default_timezone_set(‘Asia/Tokyo’) ;
 $str = date(“Y/m/d H:i:s”) ;

timefmt.hxx

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

コンソール AP で MFC

コンソール AP で,MFC(AfxWin.h など)に依存したコードを利用


新しく書いたものは,次の様なコードで可能.

  #include	"EnhMetaF.hxx"
  #include	"i_trace.hxx"
  
  int _tmain(int argc, TCHAR* argv[])
  {
    	_tsetlocale(LC_ALL,_T("")) ;
    	{
      		EnhMetaF	emf ;
      		CMetaFileDC*	mfdc = emf.GetDC() ;
      		mfdc->Rectangle(10,10,30,20) ;
    		}
    	return 0 ;
    	}

古いコードは,うまく対応できてないので…

  #undef  	_CONSOLE
  #include	<AfxWin.h>
  #include	<AfxExt.h>
  #include	<AfxCmn.h>
  #ifdef	_WIN32
  #define  	_WINDOWS
  #endif
  #include	"MessCon.hxx"
  #include	"MessBar.hxx"
  #ifdef	MessageBar
    #undef	MessageBar
    #define	MessageBar	MessageCon
    #undef	I_SUPPORT_MESSAGE_MFC
  #endif
  #include	"MessWrap.hxx"
  // ...
  int _tmain(int argc, TCHAR* argv[])
  {
    	#ifdef	_MFC_VER
    	if (!::AfxWinInit(::GetModuleHandle(NULL),NULL,::GetCommandLine(),0)) {
      		return	1 ;
      		}
    	#else
    	_tsetlocale(LC_ALL,_T("")) ;
    	#endif
    //	...
    	}

undef の幾つかは,自コードの対応のために必要.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

vector 要素の削除

MSDN vector::erase
MFC の CArray::RemoveAt(index,count=1)
 先頭要素の削除
  v1.erase( v1.begin( ) );
 [1] の削除
  v1.erase( v1.begin( )+1 );

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

コンマ演算子

古いデバッグ用のコードを見ていたら,こんなのがあった.
 while (_ftprintf(stderr,_T(“%s=”),_T(“入力してください”)) ,
  _fgetts(buf,sizeof(buf),stdin) != NULL) { … }


最近あまりこの様なコードを書くことがなく忘れていた.
 while の条件式の括弧の中に複数の文.コンマで区切られている.
 for ではインクリメントなどの変化式で使う.


MSDN コンマ演算子: ,
 次の様にすると,i には c が代入されるらしい.
   i = ( b , c ) ;
 括弧がないと b .
   i = b , c ;


MSDN コンマ演算子 (,) (JavaScript)
JavaScript でも同じ様な動作なら,今やっている所で使えそう.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

SceneJS

Cube.imo (0,0,0)-(1000,1000,1000) のデータに対して,
 translate X:-500 , y:-500 , z:500


spinYaw で,回転.spinPitch は上下方向.
yaw , pitch で最初の位置(角度で単位は度?).
zoom が中心までの相対位置?
zoomSensitivity は拡大率.
 yaw : 30 ,
 pitch : -10 ,
 zoom : 2500,
 zoomSensitivity : 100 ,
 spinYaw : 0.3 ,
cube_imo.html


yaw : 90 で右から.180 で後ろから.
pitch : -20 としているので,
 translate の y は中心でなく高さの 30% の位置にしている.
どうも材質の指定(obj の mtl など)は,効いてないみたい.
 script 内の type:”texture” , src: … で指定する?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

html style

今まで HTML の範囲としていたので次の様にしていたが,
 static Xml_E img   (c_tstring& src) {
   Xml_E img_(HTM_img) ;
     img_.AddAttribute(HTM_src,src) ;
   return img_ ;
   }

 static Xml_E img_b  (c_tstring& src) {
   Xml_E img = HtmOut::img(src) ;
     img.AddAttribute(HTM_border,_T("1")) ;
   return img ;
   }
 static Xml_E img_b_at_w (c_tstring& src,c_tstring& name,c_tstring& width) {
   Xml_E img = HtmOut::img_b(src) ;
     img.AddAttribute(HTM_alt, name) ;
     img.AddAttribute(HTM_title, name) ;
    if (!width.empty()) {
     img.AddAttribute(HTM_width, width) ;
     }
   return img ;
   }

css を利用することにより,もう少し簡単にできそう.


ここの記述で,タブサイズを指定したが,
<code style=” -o-tab-size: 4 ; -moz-tab-size: 4 ; tab-size: 4 ;”>
Blogger では,記事を書いて「保存」すると” “(半角スペース)に置換えられてしまう.


css のコメントは,C 等の様に /* */

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

BRD-UT16WX 追加

BRD-UT16WX を追加.
KYLIE HITS DVD EDITION の DVD を再生できることは確認.
BTF BD は,再生できてない.この環境(T5400)ではできないのか?


Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

WD Cloud に WordPress

WD Cloud に WordPress を追加してみた.
http://wdcloud/wordpress/ でアクセスできる様ではあるが…
また,直接 \\WDCloud\wordpress\ は見えない.


今度は,DS115j に WordPress を追加.
DS115j WordPress
http://121.108.xx.xx/wordpress/ でアクセス可能なことを確認.


Akismet をインストール.
iwaoalles.wordpress.com を移行.
Jetpack はうまく設定できていない.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

jQuery.Treeview

jQueryでエクスプローラ風メニューに!」を参考にやってみたが…

ソースを表示して,

その先を開くと,

jquery.treeview.js の指定が間違っていた.
http://121.108.xx.xx/~Iwao/T_treevw/

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Envy100 はがきがうまく給紙されない

毎年悩まされるはがきの給紙.
去年は「アクセスドア」を開けた所のローラーのクリーニングで解決できたと思ったが…
今回は,さらに裏返して「用紙ピックローラー」もクリーニングしてなんとかトラブル回避.
ENVY 100 ローラーのクリーニング

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

Dropbox が…

Dropbox が起動しなくなっていた.
exe を起動しても,10 秒程度で終了してしまう.
%Temp% にログがあったので見てみると,

bn.BUILD_KEY: Dropbox
bn.VERSION: 15.4.22
bn.DROPBOXEXT_VERSION: 3.0
bn.is_frozen: True
pid: 8680
cwd: u'C:\\Users\\Iwao\\AppData\\Roaming\\Dropbox\\bin'
     real_path=u'C:\\Users\\Iwao\\AppData\\Roaming\\Dropbox\\bin'
           	mode=040777	uid=0	gid=0
     parent	mode=040777	uid=0	gid=0
HOME: None
appdata: u'C:\\Users\\Iwao\\AppData\\Local\\Dropbox\\instance1'
         real_path=u'C:\\Users\\Iwao\\AppData\\Local\\Dropbox\\instance1'
               	mode=040777	uid=0	gid=0
         parent	mode=040777	uid=0	gid=0
dropbox_path: u'C:\\Users\\Public\\Documents\\Dropbox'
              real_path=u'C:\\Users\\Public\\Documents\\Dropbox'
                    	mode=040555	uid=0	gid=0
              parent	mode=040555	uid=0	gid=0
sys_executable: 'C:\\Users\\...\\Roaming\\Dropbox\\bin\\Dropbox.exe'
                real_path='C:\\Users\\...\\Roaming\\Dropbox\\bin\\Dropbox.exe'
                      	mode=0100777	uid=0	gid=0
                parent	mode=040777	uid=0	gid=0
trace.__file__: 'C:\\...\\Dropbox\\bin\\Dropbox.exe\\dropbox\\...\\boot_error.pyo'
                real_path='C:\\...\\Dropbox\\bin\\Dropbox.exe\\...\\boot_error.pyo'
                      	not found
                parent	not found
TMP: C:\Users\Iwao\AppData\Local\Temp
TEMP: C:\Users\Iwao\AppData\Local\Temp
tempdir: u'c:\\users\\iwao\\appdata\\local\\temp'
         real_path=u'c:\\users\\iwao\\appdata\\local\\temp'
               	mode=040777	uid=0	gid=0
         parent	mode=040777	uid=0	gid=0
Traceback (most recent call last):
  File "dropbox\client\main.pyo", line 5534, in main_startup
  File "dropbox\client\main.pyo", line 2264, in run
  File "ui\common\uikit.pyo", line 516, in create_ui_kit
  File "dropbox\client\ui\qt\__init__.pyo", line 13, in 
  File "PyQt5\QtCore.pyo", line 12, in 
  File "PyQt5\QtCore.pyo", line 10, in __load
ImportError: DLL load failed: 指定されたモジュールが見つかりません。

https://www.dropbox.com/install からダウンロードしてインストールすることにより,動作可能になった.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

HICON -> DIB

i_DIB	GetIcon_DIB	(LPCTSTR filePath,const long size=300)
{
    i_DIB	dib ;
    HICON	hIcon  = ::DImageS_GetIcon(filePath) ;
    if (hIcon != NULL)	{
        MemoryDC	memDC ;
        memDC.Init(CSize(size,size),32) ;
        CDC*		mem_dc = memDC.GetMemoryDC() ;
        mem_dc->FillSolidRect(CRect(0,0,size,size),RGB(240,240,255)) ;
        ::Icon_Draw(mem_dc->GetSafeHdc(),CRect(10,10,size-10,size-10),hIcon,TRUE,TRUE) ;
        dib = ::ToDIB(memDC) ;
        memDC.Term() ;
        ::DestroyIcon(hIcon) ;
        }
    return	dib ;
    }
Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

NUC , Synology …

DropboxWD CloudHDL-AHW を使用してきたが…
Web サーバの環境を持ちたいと思い,ちょっと調べてみた (幾つかは今まで使用していての個人的な感想).


まず 1 年位前に一度調べた情報
以前はアイオーデータやバッファローから出ていた NAS で,Web サーバ機能が使えた?
アイオーデータ   リモートリンク機能紹介   Remote Link   HDL-S , HDL2-S
バッファロー    Web サーバー機能  搭載機能一覧
他に QNAP なども見たが,その時はそれ以上時間が取れずにそこで終わっていた.
また,WD Cloud で 1 ファイルや,あるフォルダ以下などのアクセスはできていたので特に困ることはなかった.


最近になり,夏の事と,2017/10/31 に ここ(//www.ac.auone-net.jp/~iwao.n/) が使えなくなるとメールが来てまた検討し始めた.
WD Cloud でいろいろとやってみたが,単一ファイル以外はあまり使い勝手がよくない.
Windows PC であれば IIS が使えるので,NUC に絞って調べていた.
価格や消費電力を考えると手頃なものからあるが,耐久性(24 時間入れっぱなしや熱)に問題がありそう.
物によってはストレージ(C ドライブ)の容量不足の不安もあり.


WD Red 搭載の NAS を使い始めて 2 年半位になるが,自分の用途ではそれなりに安定していると思う.
環境仕様の動作時温度が 0~65 とあるので少し安心感がある (WD Cloud で夏場 60 ℃ 近くになることがあった).
また,HDD 自体よりもコントローラ部が壊れることがそれなりにある様に感じる.


Synology と QNAP を悩んでいるが,DSM 6.0 ライブデモというのがあった.
  QNAP のライブデモ .  ASUSTOR の ADM – Live Demo
今の所,DS115j + WD Red か?本当は DS116 の方が良さそうだが,そこまで使うかがわからないので…
Synology NAS ユーザーガイド DSM 6.0 基準


2020/09 http://mish.work/joomla/various/nas/nas.html
























Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

HVTR-BCTX3 リモート視聴

この夏実家に帰ったのでその時試したこと.


Win 10 T90Chi を使用.
インターネット経由で,「持ち出せる番組」を問題なく視聴可能なことを確認.
 ただ,起動直後の安定するまでは?操作を「ゆっくり」の方が良いみたい.
 宅内での操作と同様に行うと「接続エラー」になることがあった.


帰りの新幹線で,名古屋を過ぎて新横浜の手前位まで.
モバイルルータは,MR03LN .
録りためたアニメを視聴してみた.
 予想通りではあるが,長いトンネルでは途切れたり再生が止まったりした.
 それ以外の場所では特に問題なく視聴可能だった.
 早送りなどのスキップ操作は,あまり思うように操作できなかった.


2016/08/21
以前,DR で録画したものなどの宅内での視聴で途切れていた様に思うが,大丈夫になった?
 Win 10 1607 ?

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.