OSDN Git Service

add: db table updater script.
authorSushi-k <epgrec@park.mda.or.jp>
Thu, 25 Feb 2010 08:09:36 +0000 (17:09 +0900)
committerSushi-k <epgrec@park.mda.or.jp>
Thu, 25 Feb 2010 08:09:36 +0000 (17:09 +0900)
Settings.class.php
config.php.sample
do-record.sh.test
epgrec_upgrade.php [deleted file]
templates/envSetting.html
upgrade_to_201002.php [new file with mode: 0755]

index acfc8c0..6f93d7f 100755 (executable)
@@ -18,7 +18,11 @@ class Settings extends SimpleXMLElement {
                                $obj->autorec_mode = 0;
                                $obj->save();
                        }
-                       
+                       // CSの録画
+                       if( $obj->exists("cs_rec_flg") == 0 ) {
+                               $obj->cs_rec_flg = 0;
+                               $obj->save();
+                       }
                        return $obj;
                }
                else {
@@ -143,4 +147,4 @@ class Settings extends SimpleXMLElement {
                $this->asXML(INSTALL_PATH . self::CONFIG_XML);
        }
 }
-?>
\ No newline at end of file
+?>
index 53b8751..d0e13a3 100755 (executable)
@@ -43,13 +43,12 @@ $RECORD_MODE = array(
                'suffix' => '.ts',      // ファイル名のサフィックス
        ),
        
-       /* Examples is as follows.
-       
        1 => array(
-               'name' => 'Min PID',
-               'suffix' => '_tss.ts',
+               'name' => 'Minimum TS', // 最小のTS
+               'suffix' => '_tss.ts',  // do-record.shのカスタマイズが必要
        ),
        
+       /* Example is as follows.
        2 => array(
                'name' => '12Mbps MPEG4',
                'suffix' => '.avi',
@@ -216,7 +215,7 @@ define( "RESERVE_STRUCT",
        "type varchar(8) not null default 'GR',".                               // 種別(GR/BS/CS)
        "channel varchar(10) not null default '0',".                    // チャンネル
        "title varchar(512) not null default 'none',".                  // タイトル
-       "description varchar(512) not null default ' ',".               // 説明 text->varchar
+       "description varchar(512) not null default 'none',".    // 説明 text->varchar
        "category_id integer not null default '0',".                    // カテゴリID
        "starttime datetime not null default '1970-01-01 00:00:00',".   // 開始時刻
        "endtime datetime not null default '1970-01-01 00:00:00',".             // 終了時刻
@@ -226,7 +225,9 @@ define( "RESERVE_STRUCT",
        "reserve_disc varchar(128) not null default 'none',".   // 識別用hash
        "autorec integer not null default '0',".                                // キーワードID
        "mode integer not null default '0',".                                           //録画モード
-       "index reserve_idx (channel_disc, starttime)"                   // インデックス
+       "index reserve_ch_idx (channel_disc),".                 // インデックス
+       "index reserve_st_idx (starttime)".
+       ""
 );
 
 
@@ -244,8 +245,9 @@ define( "PROGRAM_STRUCT",
        "endtime datetime not null default '1970-01-01 00:00:00',".             // 終了時刻
        "program_disc varchar(128) not null default 'none',".                   // 識別用hash
        "autorec boolean not null default '1',".                                        // 自動録画有効無効
-       "index program_idx (channel_disc, starttime)"                   // インデックス
-
+       "index program_ch_idx (channel_disc),".                 // インデックス
+       "index program_st_idx (starttime)".
+       ""
 );
 
 
@@ -274,6 +276,6 @@ define( "KEYWORD_STRUCT",
        "category_id integer not null default '0',".                    // カテゴリID
        "use_regexp boolean not null default '0',".                             // 正規表現を使用するなら1
        "autorec_mode integer not null default '0',".                                           // 自動録画のモード02/23/2010追加
-       "weekofday enum ('0','1','2','3','4','5','6','7' ) default '7'"         // 曜日
+       "weekofday enum ('0','1','2','3','4','5','6','7' ) default '7'"         // 曜日、同追加
 );
 ?>
\ No newline at end of file
index 0005571..e319e0f 100755 (executable)
@@ -5,9 +5,10 @@ echo "OUTPUT  : $OUTPUT"
 echo "TUNER : $TUNER"
 echo "TYPE : $TYPE"
 echo "MODE : $MODE"
+echo "SID  : $SID"
 
 RECORDER=/usr/local/bin/recpt1
 B25=/usr/local/bin/b25_bcas
 
 /bin/date >${OUTPUT}
-#$RECORDER $CHANNEL $DURATION ${OUTPUT} --b25 --strip >/dev/null
+printenv >>${OUTPUT}
diff --git a/epgrec_upgrade.php b/epgrec_upgrade.php
deleted file mode 100755 (executable)
index aba1a8f..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/php
-<?php
-include_once('config.php');
-include_once(INSTALL_PATH . '/Settings.class.php' );
-
-$settings = Settings::factory();
-
- $dbh = mysql_connect( $settings->db_host, $settings->db_user, $settings->db_pass );
- if( $dbh !== false ) {
-       
-       $sqlstr = "use ".$settings->db_name;
-       mysql_query( $sqlstr );
-       
-       $sqlstr = "set NAMES 'utf8'";
-       mysql_query( $sqlstr );
-       
-       // RESERVE_TBL
-       // description -> text
-       $sqlstr = "alter table ".RESERVE_TBL." modify description text default null;";
-       mysql_query( $sqlstr );
-       // path -> blob
-       $sqlstr = "alter table ".RESERVE_TBL." modify path blob default null;";
-       mysql_query( $sqlstr );
-       
-       // PROGRAM_TBL
-       // descripton -> text
-       $sqlstr = "alter table ".PROGRAM_TBL." modify description text default null;";
-       mysql_query( $sqlstr );
- }
- else exit( "Can't connect DB\n");
-
-?>
\ No newline at end of file
index c869f57..df9c2f2 100755 (executable)
@@ -115,9 +115,9 @@ div.setting { padding: 0px; margin-left: 20px; margin-bottom: 20px;}
 </div>
 
 
-<h3>キーワード自動録画の録画モード</h3>
+<h3>優先する録画モード</h3>
 <div class="setting">
-<div class="caption">ã\82­ã\83¼ã\83¯ã\83¼ã\83\89è\87ªå\8b\95é\8c²ç\94»ã\82\92è¡\8cã\81\86ç\95ªçµ\84ã\81®é\8c²ç\94»ã\83¢ã\83¼ã\83\89ã\82\92設å®\9aã\81\97ã\81¾ã\81\99ã\80\82config.phpã\81®$RECORD_MODEã\81«è¤\87æ\95°ã\81®é\8c²ç\94»ã\83¢ã\83¼ã\83\89ã\82\92ç\99»é\8c²ã\81\97ã\81¦ã\81\84ã\82\8bã\81®ã\81§ã\81\82ã\82\8cã\81°ã\80\81ã\81\93ã\81®è¨­å®\9aã\81§ã\82­ã\83¼ã\83¯ã\83¼ã\83\89è\87ªå\8b\95é\8c²ç\94»ã\81®é\8c²ç\94»ã\83¢ã\83¼ã\83\89ã\82\92å¤\89æ\9b´できます。デフォルトはモード0です。
+<div class="caption">ã\82­ã\83¼ã\83¯ã\83¼ã\83\89è\87ªå\8b\95é\8c²ç\94»ã\82\84ç°¡æ\98\93é\8c²ç\94»ã\82\92è¡\8cã\81\86ç\95ªçµ\84ã\81®é\8c²ç\94»ã\83¢ã\83¼ã\83\89ã\82\92設å®\9aã\81\97ã\81¾ã\81\99ã\80\82config.phpã\81®$RECORD_MODEã\81«è¤\87æ\95°ã\81®é\8c²ç\94»ã\83¢ã\83¼ã\83\89ã\82\92ç\99»é\8c²ã\81\97ã\80\81do-record.shã\82\92ã\82«ã\82¹ã\82¿ã\83\9eã\82¤ã\82ºã\81¦ã\81\84ã\82\8bã\81®ã\81§ã\81\82ã\82\8cã\81°ã\80\81ã\81\9dã\81®é\8c²ç\94»ã\83¢ã\83¼ã\83\89ã\82\92å\84ªå\85\88ã\81\97ã\81¦å\88©ç\94¨ã\81§ã\81\8dã\81¾ã\81\99ã\80\82ã\82­ã\83¼ã\83¯ã\83¼ã\83\89è\87ªå\8b\95é\8c²ç\94»ã\81¯ã\82­ã\83¼ã\83¯ã\83¼ã\83\89ç\99»é\8c²æ\99\82ã\81«é\8c²ç\94»ã\83¢ã\83¼ã\83\89ã\82\92設å®\9aã\81\99ã\82\8bã\81\93ã\81¨ã\82\82できます。デフォルトはモード0です。
 </div>
 <select name="autorec_mode" id="id_autorec_mode" >
 {foreach from=$record_mode item=mode name=recmode}
diff --git a/upgrade_to_201002.php b/upgrade_to_201002.php
new file mode 100755 (executable)
index 0000000..1844ed5
--- /dev/null
@@ -0,0 +1,138 @@
+#!/usr/bin/php
+<?php
+include_once('config.php');
+include_once(INSTALL_PATH . '/Settings.class.php' );
+
+
+// mysqli::multi_queryは動作がいまいちなので使わない
+
+function multi_query( $sqlstrs, $dbh ) {
+       $error = false;
+       
+       foreach( $sqlstrs as $sqlstr ) {
+               $res = mysql_query( $sqlstr );
+               if( $res === FALSE ) {
+                       echo "failed: ". $sqlstr . "\n";
+                       $error = true;
+               }
+       }
+       return $error;
+}
+
+
+$settings = Settings::factory();
+$dbh = mysql_connect( $settings->db_host, $settings->db_user, $settings->db_pass );
+if( $dbh !== FALSE ) {
+
+       $sqlstr = "use ".$settings->db_name;
+       mysql_query( $sqlstr );
+
+       $sqlstr = "set NAMES 'utf8'";
+       mysql_query( $sqlstr );
+       
+       // RESERVE_TBL
+
+       $sqlstrs = array (
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  channel_disc varchar(128) not null default 'none';",        // channel disc
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  channel_id integer not null  default '0';",                 // channel ID
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  program_id integer not null default '0';",                          // Program ID
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  type varchar(8) not null default 'GR';",                            // 種別(GR/BS/CS)
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  channel varchar(10) not null default '0';",                 // チャンネル
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  title varchar(512) not null default 'none';",                       // タイトル
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  description varchar(512) not null default 'none';",         // 説明 text->varchar
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  category_id integer not null default '0';",                 // カテゴリID
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  starttime datetime not null default '1970-01-01 00:00:00';",        // 開始時刻
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  endtime datetime not null default '1970-01-01 00:00:00';",          // 終了時刻
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  job integer not null default '0';",                                 // job番号
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  path blob default null;",                                                           // 録画ファイルパス
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  complete boolean not null default '0';",                            // 完了フラグ
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  reserve_disc varchar(128) not null default 'none';",        // 識別用hash
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  autorec integer not null default '0';",                             // キーワードID
+        "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  mode integer not null default '0';",                                        //録画モード
+       );
+       
+       if( multi_query( $sqlstrs, $dbh ) ) {
+               echo "予約テーブルのアップデートに失敗\n";
+       }
+       
+       $sqlstrs = array(
+        "create index reserve_ch_idx on ".$settings->tbl_prefix.RESERVE_TBL."  (channel_disc);",
+        "create index reserve_st_idx on ".$settings->tbl_prefix.RESERVE_TBL."  (starttime);",
+       );
+       
+       if( multi_query( $sqlstrs, $dbh ) ) {
+               echo "予約テーブルにインデックスが作成できません\n";
+       }
+       
+       // PROGRAM_TBL
+       
+       $sqlstrs = array (
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify channel_disc varchar(128) not null default 'none';",  // channel disc
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify channel_id integer not null default '0';",                            // channel ID
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify type varchar(8) not null default 'GR';",                              // 種別(GR/BS/CS)
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify channel varchar(10) not null default '0';",                   // チャンネル
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify title varchar(512) not null default 'none';",                 // タイトル
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify description varchar(512) not null default 'none';",   // 説明 text->varchar
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify category_id integer not null default '0';",                   // カテゴリID
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify starttime datetime not null default '1970-01-01 00:00:00';",  // 開始時刻
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify endtime datetime not null default '1970-01-01 00:00:00';",            // 終了時刻
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify program_disc varchar(128) not null default 'none';",                  // 識別用hash
+               "alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify autorec boolean not null default '1';",                                       // 自動録画有効無効
+       );
+       
+       if( multi_query( $sqlstrs, $dbh ) ) {
+               echo "番組テーブルのアップデートに失敗\n";
+       }
+       
+       $sqlstrs = array(
+        "create index program_ch_idx on ".$settings->tbl_prefix.PROGRAM_TBL." (channel_disc);",                // インデックス
+        "create index program_st_idx on ".$settings->tbl_prefix.PROGRAM_TBL." (starttime);",                   // インデックス
+       );
+       
+       if( multi_query( $sqlstrs, $dbh ) ) {
+               echo "番組テーブルにインデックスが作成できません\n";
+       }
+       
+       // CHANNEL_TBL
+       
+       $sqlstrs = array(
+       "alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify type varchar(8) not null default 'GR';",                              // 種別
+       "alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify channel varchar(10) not null default '0';",                   // channel
+       "alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify name varchar(512) not null default 'none';",                  // 表示名
+       "alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify channel_disc varchar(128) not null default 'none';",  // 識別用hash
+       "alter table ".$settings->tbl_prefix.CHANNEL_TBL." add sid varchar(64) not null default 'hd'",                          // サービスID用02/23/2010追加
+       );
+       
+       if( multi_query( $sqlstrs, $dbh ) ) {
+               echo "チャンネルテーブルのアップデートに失敗\n";
+       }
+       
+       // CATEGORY_TBL
+       
+       $sqlstrs  = array(
+       "alter table ".$settings->tbl_prefix.CATEGORY_TBL." modify name_jp varchar(512) not null default 'none';",              // 表示名
+       "alter table ".$settings->tbl_prefix.CATEGORY_TBL." modify name_en varchar(512) not null default 'none';",              // 同上
+       "alter table ".$settings->tbl_prefix.CATEGORY_TBL." modify category_disc varchar(128) not null default 'none'", // 識別用hash
+       );
+       if( multi_query( $sqlstrs, $dbh ) ) {
+               echo "カテゴリテーブルのアップデートに失敗\n";
+       }
+       
+       // KEYWORD_TBL
+       
+       $sqlstrs = array(
+        "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify keyword varchar(512) not null default '*';",                 // 表示名
+        "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify type varchar(8) not null default '*';",                              // 種別
+        "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify channel_id integer not null default '0';",                           // channel ID
+        "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify category_id integer not null default '0';",                  // カテゴリID
+        "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify use_regexp boolean not null default '0';",                           // 正規表現を使用するなら1
+        "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add autorec_mode integer not null default '0';",                                            // 自動録画のモード02/23/2010追加
+        "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add weekofday enum ('0','1','2','3','4','5','6','7' ) default '7'",         // 曜日、同追加
+       );
+       if( multi_query( $sqlstrs, $dbh ) ) {
+               echo "キーワードテーブルのアップデートに失敗\n";
+       }
+}
+else
+       exit( "DBの接続に失敗\n" );
+?>
\ No newline at end of file