Changeset 12606
- Timestamp:
- Aug 12, 2009, 10:46:42 AM (13 years ago)
- Location:
- OpenPNE/branches/stable-2.14.x/setup/script
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE/branches/stable-2.14.x/setup/script/update/update01-for2.13.8-insert_image_size.php
r12585 r12606 2 2 require_once './config.inc.php'; 3 3 chdir(OPENPNE_PUBLIC_HTML_DIR); 4 require_once (OPENPNE_WEBAPP_DIR . "/init.inc");4 require_once OPENPNE_WEBAPP_DIR . '/init.inc'; 5 5 6 //---------- 7 //- 登録済み画像のファイルサイズを求める 6 /** 7 * 登録済み画像のファイルサイズを求める 8 */ 8 9 function get_image_size($category, $params, $handle) 9 10 { … … 14 15 15 16 // c_image 参照先 16 $image_dsn = array('main', 'image');17 $image_dsn = array('main', 'image'); 17 18 foreach ($image_dsn as $key => $dsn) { 18 19 if (!isset($GLOBALS['_OPENPNE_DSN_LIST'][$dsn])) { … … 22 23 23 24 // 取り出し 24 $sql = "SELECT ";25 if ($table <> "biz_shisetsu") {26 $sql .= " $c_member_id as c_member_id, ";25 $sql = 'SELECT '; 26 if ($table <> 'biz_shisetsu') { 27 $sql .= $c_member_id . ' as c_member_id, '; 27 28 } 28 $sql .= "$filename as image_filename ";29 if ($table == "c_member") {30 $sql .= ",r_date ";31 } elseif ($table <> "biz_group" && $table <> "biz_shisetsu") {32 $sql .= ",r_datetime ";29 $sql .= $filename . ' as image_filename '; 30 if ($table == 'c_member') { 31 $sql .= ',r_date '; 32 } elseif ($table <> 'biz_group' && $table <> 'biz_shisetsu') { 33 $sql .= ',r_datetime '; 33 34 } 34 $sql .= "FROM "; 35 $sql .= " $table "; 36 $sql .= "WHERE "; 37 $sql .= " $filename <> '' "; 38 $sql .= "AND "; 39 $sql .= " $filename is not NULL"; 35 $sql .= 'FROM ' . $table; 36 $sql .= ' WHERE ' . $filename . ' <> ""'; 37 $sql .= ' AND ' . $filename . ' is not NULL'; 40 38 $data_list = db_get_all($sql); 41 39 42 40 $lines = 0; 43 41 if ($data_list) { 44 fwrite($handle, "INSERT INTO c_image_size VALUES");42 fwrite($handle, 'INSERT INTO c_image_size VALUES'); 45 43 } 46 44 foreach($data_list as $data) { … … 54 52 } 55 53 56 $ins_data = "";54 $ins_data = ''; 57 55 if ($lines) { 58 $ins_data .= ",";56 $ins_data .= ','; 59 57 } 60 $ins_data .= "(";58 $ins_data .= '('; 61 59 if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { 62 60 $ins_data .= " nextval('c_image_size_c_image_size_id_seq')"; 63 61 } else { 64 $ins_data .= " null";62 $ins_data .= ' null'; 65 63 } 66 64 $ins_data .= ",'" . $data['image_filename'] . "'"; … … 68 66 $ins_data .= ",'" . $filesize . "'"; 69 67 $ins_data .= ",'" . $category . "'"; 70 if ($table == "biz_group" || $table == "biz_shisetsu") {68 if ($table == 'biz_group' || $table == 'biz_shisetsu') { 71 69 $ins_data .= ",'" . db_now() . "'"; 72 } elseif ($table == "c_member") {70 } elseif ($table == 'c_member') { 73 71 $ins_data .= ",'" . $data['r_date'] . "'"; 74 72 } else { 75 73 $ins_data .= ",'" . $data['r_datetime'] . "'"; 76 74 } 77 $ins_data .= ")";75 $ins_data .= ')'; 78 76 fwrite($handle, $ins_data); 79 77 $lines ++; … … 86 84 } 87 85 88 //---------- 89 //- テンポラリファイルを作成 86 /** 87 * テンポラリファイルを作成 88 */ 90 89 function open_temp_file($mode, $filename = '') 91 90 { 92 91 if (!$filename) { 93 $w_filename = tempnam(OPENPNE_VAR_DIR . "/tmp", "image_size");92 $w_filename = tempnam(OPENPNE_VAR_DIR . '/tmp', 'image_size'); 94 93 } else { 95 94 $w_filename = $filename; … … 100 99 } 101 100 102 //---------- 103 //- load data infile 101 /** 102 * load data infile 103 */ 104 104 function load_data_infile($filename) 105 105 { 106 list($r_filename, $r_handle) = open_temp_file( "r", $filename);106 list($r_filename, $r_handle) = open_temp_file('r', $filename); 107 107 while (!feof($r_handle)) { 108 108 $sql = fgets($r_handle); … … 112 112 } 113 113 114 //---------- 115 //- テンポラリを閉じる 114 /** 115 * テンポラリを閉じる 116 */ 116 117 function close_temp_file($filename, $handle) 117 118 { … … 121 122 122 123 123 //---------- 124 //- 処理本体 125 //---------- 126 // biz_shisetsuは、member_idを持っていないため、設定不可 127 128 // array([category] => array([table],[filename field],[c_member_id field])) 129 124 /** 125 * 処理本体 126 * biz_shisetsuは、member_idを持っていないため、設定不可 127 * array([category] => array([table],[filename field],[c_member_id field]) 128 */ 130 129 $category_list = array( 131 132 133 134 135 array('c_commu_topic_comment', 'image_filename1', 'c_member_id')136 ,array('c_commu_topic_comment', 'image_filename2', 'c_member_id')137 ,array('c_commu_topic_comment', 'image_filename3', 'c_member_id')138 139 140 array('c_diary', 'image_filename_1', 'c_member_id')141 ,array('c_diary', 'image_filename_2', 'c_member_id')142 ,array('c_diary', 'image_filename_3', 'c_member_id')143 ,array('c_diary_comment', 'image_filename_1', 'c_member_id')144 ,array('c_diary_comment', 'image_filename_2', 'c_member_id')145 ,array('c_diary_comment', 'image_filename_3', 'c_member_id')146 ,array('c_album', 'album_cover_image', 'c_member_id')147 148 149 array('c_commu', 'image_filename', 'c_member_id_admin')150 ,array('biz_group', 'image_filename', 'admin_id')151 ,array('biz_shisetsu', 'image_filename', 'c_member_id')152 ,array('c_member', 'image_filename_1', 'c_member_id')153 ,array('c_member', 'image_filename_2', 'c_member_id')154 ,array('c_member', 'image_filename_3', 'c_member_id')155 ,array('c_message', 'image_filename_1', 'c_member_id_from')156 ,array('c_message', 'image_filename_2', 'c_member_id_from')157 ,array('c_message', 'image_filename_3', 'c_member_id_from')158 )159 130 'album' => array( 131 array('c_album_image', 'image_filename', 'c_member_id') 132 ), 133 'commu' => array( 134 array('c_commu_topic_comment', 'image_filename1', 'c_member_id'), 135 array('c_commu_topic_comment', 'image_filename2', 'c_member_id'), 136 array('c_commu_topic_comment', 'image_filename3', 'c_member_id'), 137 ), 138 'diary' => array( 139 array('c_diary', 'image_filename_1', 'c_member_id'), 140 array('c_diary', 'image_filename_2', 'c_member_id'), 141 array('c_diary', 'image_filename_3', 'c_member_id'), 142 array('c_diary_comment', 'image_filename_1', 'c_member_id'), 143 array('c_diary_comment', 'image_filename_2', 'c_member_id'), 144 array('c_diary_comment', 'image_filename_3', 'c_member_id'), 145 array('c_album', 'album_cover_image', 'c_member_id'), 146 ), 147 'other' => array( 148 array('c_commu', 'image_filename', 'c_member_id_admin'), 149 array('biz_group', 'image_filename', 'admin_id'), 150 array('biz_shisetsu', 'image_filename', 'c_member_id'), 151 array('c_member', 'image_filename_1', 'c_member_id'), 152 array('c_member', 'image_filename_2', 'c_member_id'), 153 array('c_member', 'image_filename_3', 'c_member_id'), 154 array('c_message', 'image_filename_1', 'c_member_id_from'), 155 array('c_message', 'image_filename_2', 'c_member_id_from'), 156 array('c_message', 'image_filename_3', 'c_member_id_from'), 157 ), 158 ); 160 159 161 160 // Insert格納用テンポラリファイル作成 162 list($filename, $handle) = open_temp_file( "w");161 list($filename, $handle) = open_temp_file('w'); 163 162 164 163 //テーブル分ループ … … 178 177 load_data_infile($filename); 179 178 180 // テンポラリファイル削除181 //unlink($filename);182 183 179 echo 'Complete!'; 184 180 ?> -
OpenPNE/branches/stable-2.14.x/setup/script/upgrade/upgrade01.php
r12585 r12606 2 2 require_once './config.inc.php'; 3 3 chdir(OPENPNE_PUBLIC_HTML_DIR); 4 require_once (OPENPNE_WEBAPP_DIR . "/init.inc");4 require_once OPENPNE_WEBAPP_DIR . '/init.inc'; 5 5 6 //---------- 7 //- 登録済み画像のファイルサイズを求める 6 /** 7 * 登録済み画像のファイルサイズを求める 8 */ 8 9 function get_image_size($category, $params, $handle) 9 10 { … … 14 15 15 16 // c_image 参照先 16 $image_dsn = array('main', 'image');17 $image_dsn = array('main', 'image'); 17 18 foreach ($image_dsn as $key => $dsn) { 18 19 if (!isset($GLOBALS['_OPENPNE_DSN_LIST'][$dsn])) { … … 22 23 23 24 // 取り出し 24 $sql = "SELECT ";25 if ($table <> "biz_shisetsu") {26 $sql .= " $c_member_id as c_member_id, ";25 $sql = 'SELECT '; 26 if ($table <> 'biz_shisetsu') { 27 $sql .= $c_member_id . ' as c_member_id, '; 27 28 } 28 $sql .= "$filename as image_filename ";29 if ($table == "c_member") {30 $sql .= ",r_date ";31 } elseif ($table <> "biz_group" && $table <> "biz_shisetsu") {32 $sql .= ",r_datetime ";29 $sql .= $filename . ' as image_filename '; 30 if ($table == 'c_member') { 31 $sql .= ',r_date '; 32 } elseif ($table <> 'biz_group' && $table <> 'biz_shisetsu') { 33 $sql .= ',r_datetime '; 33 34 } 34 $sql .= "FROM "; 35 $sql .= " $table "; 36 $sql .= "WHERE "; 37 $sql .= " $filename <> '' "; 38 $sql .= "AND "; 39 $sql .= " $filename is not NULL"; 35 $sql .= 'FROM ' . $table; 36 $sql .= ' WHERE ' . $filename . ' <> ""'; 37 $sql .= ' AND ' . $filename . ' is not NULL'; 40 38 $data_list = db_get_all($sql); 41 39 42 40 $lines = 0; 43 41 if ($data_list) { 44 fwrite($handle, "INSERT INTO c_image_size VALUES");42 fwrite($handle, 'INSERT INTO c_image_size VALUES'); 45 43 } 46 44 foreach($data_list as $data) { … … 54 52 } 55 53 56 $ins_data = "";54 $ins_data = ''; 57 55 if ($lines) { 58 $ins_data .= ",";56 $ins_data .= ','; 59 57 } 60 $ins_data .= "(";58 $ins_data .= '('; 61 59 if ($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['phptype'] == 'pgsql') { 62 60 $ins_data .= " nextval('c_image_size_c_image_size_id_seq')"; 63 61 } else { 64 $ins_data .= " null";62 $ins_data .= ' null'; 65 63 } 66 64 $ins_data .= ",'" . $data['image_filename'] . "'"; … … 68 66 $ins_data .= ",'" . $filesize . "'"; 69 67 $ins_data .= ",'" . $category . "'"; 70 if ($table == "biz_group" || $table == "biz_shisetsu") {68 if ($table == 'biz_group' || $table == 'biz_shisetsu') { 71 69 $ins_data .= ",'" . db_now() . "'"; 72 } elseif ($table == "c_member") {70 } elseif ($table == 'c_member') { 73 71 $ins_data .= ",'" . $data['r_date'] . "'"; 74 72 } else { 75 73 $ins_data .= ",'" . $data['r_datetime'] . "'"; 76 74 } 77 $ins_data .= ")";75 $ins_data .= ')'; 78 76 fwrite($handle, $ins_data); 79 77 $lines ++; … … 86 84 } 87 85 88 //---------- 89 //- テンポラリファイルを作成 86 /** 87 * テンポラリファイルを作成 88 */ 90 89 function open_temp_file($mode, $filename = '') 91 90 { 92 91 if (!$filename) { 93 $w_filename = tempnam(OPENPNE_VAR_DIR . "/tmp", "image_size");92 $w_filename = tempnam(OPENPNE_VAR_DIR . '/tmp', 'image_size'); 94 93 } else { 95 94 $w_filename = $filename; … … 100 99 } 101 100 102 //---------- 103 //- load data infile 101 /** 102 * load data infile 103 */ 104 104 function load_data_infile($filename) 105 105 { 106 list($r_filename, $r_handle) = open_temp_file( "r", $filename);106 list($r_filename, $r_handle) = open_temp_file('r', $filename); 107 107 while (!feof($r_handle)) { 108 108 $sql = fgets($r_handle); … … 112 112 } 113 113 114 //---------- 115 //- テンポラリを閉じる 114 /** 115 * テンポラリを閉じる 116 */ 116 117 function close_temp_file($filename, $handle) 117 118 { … … 121 122 122 123 123 //---------- 124 //- 処理本体 125 //---------- 126 // biz_shisetsuは、member_idを持っていないため、設定不可 127 128 // array([category] => array([table],[filename field],[c_member_id field])) 129 124 /** 125 * 処理本体 126 * biz_shisetsuは、member_idを持っていないため、設定不可 127 * array([category] => array([table],[filename field],[c_member_id field]) 128 */ 130 129 $category_list = array( 131 132 133 134 135 array('c_commu_topic_comment', 'image_filename1', 'c_member_id')136 ,array('c_commu_topic_comment', 'image_filename2', 'c_member_id')137 ,array('c_commu_topic_comment', 'image_filename3', 'c_member_id')138 139 140 array('c_diary', 'image_filename_1', 'c_member_id')141 ,array('c_diary', 'image_filename_2', 'c_member_id')142 ,array('c_diary', 'image_filename_3', 'c_member_id')143 ,array('c_diary_comment', 'image_filename_1', 'c_member_id')144 ,array('c_diary_comment', 'image_filename_2', 'c_member_id')145 ,array('c_diary_comment', 'image_filename_3', 'c_member_id')146 ,array('c_album', 'album_cover_image', 'c_member_id')147 148 149 array('c_commu', 'image_filename', 'c_member_id_admin')150 ,array('biz_group', 'image_filename', 'admin_id')151 ,array('biz_shisetsu', 'image_filename', 'c_member_id')152 ,array('c_member', 'image_filename_1', 'c_member_id')153 ,array('c_member', 'image_filename_2', 'c_member_id')154 ,array('c_member', 'image_filename_3', 'c_member_id')155 ,array('c_message', 'image_filename_1', 'c_member_id_from')156 ,array('c_message', 'image_filename_2', 'c_member_id_from')157 ,array('c_message', 'image_filename_3', 'c_member_id_from')158 )159 130 'album' => array( 131 array('c_album_image', 'image_filename', 'c_member_id') 132 ), 133 'commu' => array( 134 array('c_commu_topic_comment', 'image_filename1', 'c_member_id'), 135 array('c_commu_topic_comment', 'image_filename2', 'c_member_id'), 136 array('c_commu_topic_comment', 'image_filename3', 'c_member_id'), 137 ), 138 'diary' => array( 139 array('c_diary', 'image_filename_1', 'c_member_id'), 140 array('c_diary', 'image_filename_2', 'c_member_id'), 141 array('c_diary', 'image_filename_3', 'c_member_id'), 142 array('c_diary_comment', 'image_filename_1', 'c_member_id'), 143 array('c_diary_comment', 'image_filename_2', 'c_member_id'), 144 array('c_diary_comment', 'image_filename_3', 'c_member_id'), 145 array('c_album', 'album_cover_image', 'c_member_id'), 146 ), 147 'other' => array( 148 array('c_commu', 'image_filename', 'c_member_id_admin'), 149 array('biz_group', 'image_filename', 'admin_id'), 150 array('biz_shisetsu', 'image_filename', 'c_member_id'), 151 array('c_member', 'image_filename_1', 'c_member_id'), 152 array('c_member', 'image_filename_2', 'c_member_id'), 153 array('c_member', 'image_filename_3', 'c_member_id'), 154 array('c_message', 'image_filename_1', 'c_member_id_from'), 155 array('c_message', 'image_filename_2', 'c_member_id_from'), 156 array('c_message', 'image_filename_3', 'c_member_id_from'), 157 ), 158 ); 160 159 161 160 // Insert格納用テンポラリファイル作成 162 list($filename, $handle) = open_temp_file( "w");161 list($filename, $handle) = open_temp_file('w'); 163 162 164 163 //テーブル分ループ … … 178 177 load_data_infile($filename); 179 178 180 // テンポラリファイル削除181 //unlink($filename);182 183 179 echo 'Complete!'; 184 180 ?>
Note: See TracChangeset
for help on using the changeset viewer.