cubsonではまる。
使っている環境は
- Windows XP
- Apache 2.2
- Xoops Cube Legacy 2.1.5
- php5.2.2
さてcubson.中でmainfile.phpを読み込んでXOOPS_DB_PREFIXを取得するのですが
static public Hashtable ParseMainFile(string filepath) { Hashtable ret = new Hashtable(); // // mainfile.php を開きます // FileStream fs = null; try { fs = new FileStream(filepath, FileMode.Open); } catch (FileNotFoundException) { // mLog.Add(new CommandErrorMessage(path + "/mainfile.php が見つかりません")); return ret; } catch (System.Security.SecurityException) { // mLog.Add(new CommandErrorMessage(path + "/mainfile.php に対して必要なアクセス権限がありません")); return ret; } catch { return ret; } // // 読み込み開始 // StreamReader reader = new StreamReader(fs); String str; while ((str = reader.ReadLine()) != null) { int startIndex = str.IndexOf("define('XOOPS_DB_PREFIX', '"); if (startIndex >= 0) { String define_code = str.Substring(startIndex); int endIndex = define_code.IndexOf("');"); int length = "define('XOOPS_DB_PREFIX', '".Length; ret["XOOPS_DB_PREFIX"] = define_code.Substring(length, (endIndex - length)); } } reader.Close(); fs.Close(); return ret; }
FileStream()がおかしい?これだと「読み書き可能」モードで開ける気がする。(今C#ないので試せない)
なのでmainfile.phpのプロパティを読み書き可能にすればウマくいける、はず。
ところでこのメソッドの呼び出し元"ParseMainFile(string filepath, string name)"なんだがXOOPS_DB_PREFIXを取り出すだけなのになんでParseMainFile?てかname使ってないし!