PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/convert/system/application/converter/controllers/Convert.php

https://github.com/usagi-project/mynets1
PHP | 243 lines | 178 code | 17 blank | 48 comment | 13 complexity | aadf92ea6721c4f3c817f97b03acdd91 MD5 | raw file
  1. <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3. * LICENSE
  4. *
  5. * This source file is subject to the new BSD license that is bundled
  6. * with this package in the file LICENSE.txt.
  7. *
  8. * @category
  9. * @package Session Class
  10. * @author KUNIHARU Tsujioka <kunitsuji@gmail.com>
  11. * @copyright Copyright (c) 2008 KUNIHARU Tsujioka <kunitsuji@gmail.com>
  12. * @copyright Copyright (c) 2006-2008 Usagi Project (URL:http://usagi-project.org)
  13. * @license New BSD License
  14. */
  15. class Convert extends Controller
  16. {
  17. var $hostname;
  18. var $username;
  19. var $password;
  20. var $dbname;
  21. var $dbprefox;
  22. function Convert()
  23. {
  24. parent::Controller();
  25. }
  26. function index()
  27. {
  28. if (strpos($this->input->post('submit'), 'MyNETS') !== FALSE)
  29. {
  30. $convert_flag = 'mynets';
  31. }
  32. else
  33. {
  34. $convert_flag = 'pne';
  35. }
  36. $this->load->helper('form');
  37. $this->load->library('session');
  38. $this->session->start();
  39. $this->username = $this->session->get('username');
  40. $this->password = $this->session->get('password');
  41. $this->dbname = $this->session->get('dbname');
  42. $this->hostname = $this->session->get('hostname');
  43. $this->dbprefix = $this->session->get('dbprefix');
  44. $db['hostname'] = $this->hostname;
  45. $db['username'] = $this->username;
  46. $db['password'] = $this->password;
  47. $db['database'] = $this->dbname;
  48. $db['dbdriver'] = "mysql";
  49. $db['dbprefix'] = $this->dbprefix;
  50. $db['pconnect'] = false;
  51. $db['db_debug'] = false;
  52. $db['char_set'] = "utf8";
  53. $db['dbcollat'] = "utf8_general_ci";
  54. $submit = $this->input->post('submit');
  55. $this->load->model('mynet_converter', '', $db);
  56. $vData = array(
  57. 'header' => 'header/header.html',
  58. 'footer' => 'header/footer.html',
  59. 'errmsg' => '',
  60. );
  61. $is_pne = 0;
  62. if ($convert_flag === 'mynets')
  63. {
  64. log_message('debug', "MyNETS database VersionUP started");
  65. //テーブルの削除
  66. $this->mynet_converter->dropTable();
  67. log_message('debug', "dropTable() finished");
  68. //新規テーブルの追加
  69. $this->mynet_converter->addTable();
  70. log_message('debug', "addTable() finished");
  71. //カラムの修正を実施 2008-08-28先に追加をしておく
  72. $this->mynet_converter->addColumns();
  73. log_message('debug', "addColumns() finished");
  74. $this->mynet_converter->modifyColumns();
  75. log_message('debug', "modifyColumns() finished");
  76. //インデックスの追加等の実施
  77. $this->mynet_converter->addIndex();
  78. log_message('debug', "addIndex() finished");
  79. //データの追加処理
  80. $this->mynet_converter->addInsertData();
  81. log_message('debug', "addInsertData() finished");
  82. //データのアップデート処理
  83. $this->mynet_converter->updateTableData();
  84. log_message('debug', "updateTableData() finished");
  85. //完了した内容を、c_versionへ記述する
  86. $this->mynet_converter->updateMyNETSVersion($this->mynet_converter->mynetsversion);
  87. log_message('debug', "updateMyNETSVersion() finished");
  88. //エラー結果を取得
  89. $errmsg = $this->mynet_converter->getError();
  90. $vData['errmsg'] = $errmsg;
  91. //エラーがない場合、データコンバートを実施する
  92. if (!$errmsg)
  93. {
  94. log_message('debug', "MyNETS data convertion started");
  95. //トピックのe_datetimeカラム追加に対して最新日付を調整する
  96. $file_path = OPENPNE_DIR . '/var/tmp';
  97. if (file_exists($file_path . '/topic_edatetime_update.txt'))
  98. {
  99. log_message('debug', "setTopiUpdate() no convert");
  100. }
  101. else
  102. {
  103. //$this->session->set('topic_edatetime', 'OK');
  104. $this->mynet_converter->setTopiUpdate();
  105. //実行履歴ファイルを作成する
  106. $fp = fopen($file_path . '/topic_edatetime_update.txt', 'w+');
  107. fwrite($fp, date(time()));
  108. fclose($fp);
  109. log_message('debug', "setTopiUpdate() finished");
  110. }
  111. //Ver1.0.1から1.1.0へ以降した際のコメント番号の集計、更新
  112. if (file_exists($file_path . '/diary_commentno_update.txt'))
  113. {
  114. log_message('debug', "setTopiUpdate() no convert");
  115. }
  116. else
  117. {
  118. //$this->session->set('topic_edatetime', 'OK');
  119. $this->mynet_converter->setDiaryCommentNo();
  120. //実行履歴ファイルを作成する
  121. $fp = fopen($file_path . '/diary_commentno_update.txt', 'w+');
  122. fwrite($fp, date(time()));
  123. fclose($fp);
  124. log_message('debug', "setDiaryCommentNo() finished");
  125. }
  126. //c_imageテーブルにc_member_idの値を取り込む
  127. $this->mynet_converter->setIdImageTable();
  128. }
  129. }
  130. else if ($convert_flag === 'pne')
  131. {
  132. log_message('debug', "OpenPNE database Convert started");
  133. $is_pne = 1;
  134. //テーブルの削除
  135. $this->mynet_converter->dropTable();
  136. log_message('debug', "dropTable() finished");
  137. //新規テーブルの追加
  138. $this->mynet_converter->addTable();
  139. log_message('debug', "addTable() finished");
  140. //カラムの修正を実施
  141. $this->mynet_converter->modifyColumns();
  142. log_message('debug', "modifyColumns() finished");
  143. $this->mynet_converter->addColumns();
  144. log_message('debug', "dropColumns() finished");
  145. //インデックスの追加等の実施
  146. $this->mynet_converter->addIndex();
  147. log_message('debug', "addIndex() finished");
  148. //データの追加処理
  149. $this->mynet_converter->addInsertData();
  150. log_message('debug', "addInsertData() finished");
  151. //データのアップデート処理
  152. $this->mynet_converter->updateTableData();
  153. log_message('debug', "updateTableData() finished");
  154. //完了した内容を、c_versionへ記述する
  155. $this->mynet_converter->updateMyNETSVersion($this->mynet_converter->mynetsversion);
  156. log_message('debug', "updateMyNETSVersion() finished");
  157. //エラー結果を取得
  158. $errmsg = $this->mynet_converter->getError();
  159. $vData['errmsg'] = $errmsg;
  160. //エラーがない場合、データコンバートを実施する
  161. if (!$errmsg)
  162. {
  163. log_message('debug', "MyNETS data convertion started");
  164. //トピックのe_datetimeカラム追加に対して最新日付を調整する
  165. $file_path = OPENPNE_DIR . '/var/tmp';
  166. if (file_exists($file_path . '/topic_edatetime_update.txt'))
  167. {
  168. log_message('debug', "setTopiUpdate() no convert");
  169. }
  170. else
  171. {
  172. //$this->session->set('topic_edatetime', 'OK');
  173. $this->mynet_converter->setTopiUpdate();
  174. //実行履歴ファイルを作成する
  175. $fp = fopen($file_path . '/topic_edatetime_update.txt', 'w+');
  176. fwrite($fp, date(time()));
  177. fclose($fp);
  178. log_message('debug', "setTopiUpdate() finished");
  179. }
  180. //Ver1.0.1から1.1.0へ以降した際のコメント番号の集計、更新
  181. if (file_exists($file_path . '/diary_commentno_update.txt'))
  182. {
  183. log_message('debug', "setTopiUpdate() no convert");
  184. }
  185. else
  186. {
  187. //$this->session->set('topic_edatetime', 'OK');
  188. $this->mynet_converter->setDiaryCommentNo();
  189. //実行履歴ファイルを作成する
  190. $fp = fopen($file_path . '/diary_commentno_update.txt', 'w+');
  191. fwrite($fp, date(time()));
  192. fclose($fp);
  193. log_message('debug', "setDiaryCommentNo() finished");
  194. }
  195. //PNEからMyNETS、diaryコメント集計及びc_diary/comment_countへの集計値移動処理
  196. if (file_exists($file_path . '/diary_commentcount_update.txt'))
  197. {
  198. log_message('debug', "setDiaryCommentCount() no convert");
  199. }
  200. else
  201. {
  202. //$this->session->set('topic_edatetime', 'OK');
  203. $this->mynet_converter->setDiaryCommentCount();
  204. //実行履歴ファイルを作成する
  205. $fp = fopen($file_path . '/diary_commentcount_update.txt', 'w+');
  206. fwrite($fp, date(time()));
  207. fclose($fp);
  208. log_message('debug', "setDiaryCommentCount() finished");
  209. }
  210. //c_imageテーブルにc_member_idの値を取り込む
  211. $this->mynet_converter->setIdImageTable();
  212. }
  213. }
  214. else //error?
  215. {
  216. }
  217. $options = array(
  218. 'OpenPNE Ver2.10.X未満から' => 'PNE2.8',
  219. 'OpenPNE Ver2.10.Xよりあと' => 'PNE2.10',
  220. );
  221. $vData['options'] = $options;
  222. $vData['is_pne'] = $is_pne;
  223. $this->load->view('convert.html', $vData);
  224. }
  225. }
  226. ?>