예제 #1
0
파일: recomplete.php 프로젝트: ha1t/epgrec
#!/usr/bin/php
<?php 
// 録画が完了したことを知らせるフラグ
// @TODO gen-thumbnailを実行する
require_once "config.php";
require_once INSTALL_PATH . "/DBRecord.class.php";
$settings = Settings::factory();
$reserve_id = $argv[1];
try {
    $rrec = new DBRecord(RESERVE_TBL, "id", $reserve_id);
    if (file_exists(INSTALL_PATH . $settings->spool . "/" . $rrec->path)) {
        // 予約完了
        $rrec->complete = '1';
    } else {
        // 予約失敗
        $rrec->delete();
    }
} catch (Exception $e) {
    exit($e->getMessage());
}
예제 #2
0
    /**
     *
     */
    function Write()
    {
        global $c, $session;
        if (parent::Write()) {
            if ($this->new_record) {
                $qry = new PgQuery("SELECT currval('organisation_org_code_seq');");
                $qry->Exec("OrganisationPlus::Write: Retrieve org_code");
                $sequence_value = $qry->Fetch(true);
                // Fetch as an array
                $org_code = $sequence_value[0];
                $GLOBALS['id'] = $org_code;
                $c->messages[] = "Organisation, System and User records created.";
                if (isset($_POST['invite']) && $_POST['invite'] == 'on') {
                    $username = $this->Get('username');
                    $fullname = $this->Get('fullname');
                    $invitation_template = <<<EOINVITE
Hi {$fullname},

Welcome to @@system_name@@!

Your access has now been configured by {$session->fullname} with the
following details:

    Username: {$username}
    Password: @@password@@

This is a temporary password which will be valid for 24 hours.  To
log on, please visit:

    {$c->base_dns}/

Once you have logged on, you will need to use the "Edit My Info"
option to set a permanent password.

If you have any problems, please contact {$session->fullname} or the
system administrator.

Thanks.

EOINVITE;
                    $session->Dbg("OrganisationPlus", "Inviting '%s' to join.", $username);
                    $session->EmailTemporaryPassword($username, null, $invitation_template);
                    $c->messages[] = "Invitation and password sent to " . $username;
                } else {
                    $session->Dbg("OrganisationPlus", "Invite is >>%s<<", $_POST['invite']);
                }
            } else {
                $c->messages[] = "Organisation, System and User details updated.";
            }
            return true;
        }
        return false;
        // Looks like we screwed up somewhere
    }
예제 #3
0
파일: index.php 프로젝트: sushi-k/epgrec
        $programs[$st]['list'][$num]['starttime'] = "";
        $programs[$st]['list'][$num]['description'] = "";
        $num++;
    }
    $st++;
}
$prec = null;
// 局の幅
$ch_set_width = $settings->ch_set_width;
// 全体の幅
$chs_width = $ch_set_width * count($channel_map);
// GETパラメタ
$get_param = $_SERVER['SCRIPT_NAME'] . "?type=" . $type . "&length=" . $program_length . "";
$smarty = new Smarty();
// カテゴリ一覧
$crec = DBRecord::createRecords(CATEGORY_TBL);
$cats = array();
$num = 0;
foreach ($crec as $val) {
    $cats[$num]['name_en'] = $val->name_en;
    $cats[$num]['name_jp'] = $val->name_jp;
    $num++;
}
$smarty->assign("cats", $cats);
// タイプ選択
$types = array();
$i = 0;
if ($settings->bs_tuners != 0) {
    $types[$i]['selected'] = $type == "BS" ? 'class="selected"' : "";
    $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=BS&length=" . $program_length . "&time=" . date("YmdH", $top_time);
    $types[$i]['name'] = "BS";
예제 #4
0
파일: step3.php 프로젝트: sushi-k/epgrec
$res = @mysql_query($sqlstr);
if ($res == false) {
    jdialog("データベース名が異なるようです", "step2.php");
    exit;
}
// DBテーブルの作成
try {
    $rec = new DBRecord(RESERVE_TBL);
    $rec->createTable(RESERVE_STRUCT);
    $rec = new DBRecord(PROGRAM_TBL);
    $rec->createTable(PROGRAM_STRUCT);
    $rec = new DBRecord(CHANNEL_TBL);
    $rec->createTable(CHANNEL_STRUCT);
    $rec = new DBRecord(CATEGORY_TBL);
    $rec->createTable(CATEGORY_STRUCT);
    $rec = new DBRecord(KEYWORD_TBL);
    $rec->createTable(KEYWORD_STRUCT);
} catch (Exception $e) {
    jdialog("テーブルの作成に失敗しました。データベースに権限がない等の理由が考えられます。", "step2.php");
    exit;
}
$smarty = new Smarty();
$smarty->template_dir = "../templates/";
$smarty->compile_dir = "../templates_c/";
$smarty->cache_dir = "../cache/";
$smarty->assign("record_mode", $RECORD_MODE);
$smarty->assign("settings", $settings);
$smarty->assign("install_path", INSTALL_PATH);
$smarty->assign("post_to", "step4.php");
$smarty->assign("sitetitle", "インストールステップ3");
$smarty->assign("message", "環境設定を行います。これらの設定はデフォルトのままでも制限付きながら動作します。");
예제 #5
0
 public static function cancel($reserve_id = 0, $program_id = 0)
 {
     $settings = Settings::factory();
     $rec = null;
     try {
         if ($reserve_id) {
             $rec = new DBRecord(RESERVE_TBL, "id", $reserve_id);
         } else {
             if ($program_id) {
                 $rec = new DBRecord(RESERVE_TBL, "program_id", $program_id);
             }
         }
         if ($rec == null) {
             throw new Exception("IDの指定が無効です");
         }
         if (!$rec->complete) {
             // 未実行の予約である
             if (strtotime($rec->starttime) < time() + PADDING_TIME + $settings->former_time) {
                 throw new Exception("過去の録画予約です");
             }
             exec($settings->atrm . " " . $rec->job);
         }
         $rec->delete();
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #6
0
파일: User.php 프로젝트: rossryan/Calico
 /**
  * Write the User record.
  * @return Success.
  */
 function Write()
 {
     global $c, $session;
     if (parent::Write()) {
         $c->messages[] = i18n('User record written.');
         if ($this->WriteType == 'insert') {
             $qry = new AwlQuery("SELECT currval('usr_user_no_seq');");
             $qry->Exec("User::Write");
             $sequence_value = $qry->Fetch(true);
             // Fetch as an array
             $this->user_no = $sequence_value[0];
         } else {
             if ($this->user_no == $session->user_no && $this->Get("date_format_type") != $session->date_format_type) {
                 // Ensure we match the date style setting
                 $session->date_format_type = $this->Get("date_format_type");
                 unset($_POST['email_ok']);
                 $qry = new AwlQuery("SET DATESTYLE TO ?;", $this->Get("date_format_type") == 'E' ? 'European,ISO' : ($this->Get("date_format_type") == 'U' ? 'US,ISO' : 'ISO'));
                 $qry->Exec();
             }
         }
         return $this->WriteRoles();
     }
     return false;
 }
예제 #7
0
 public function __destruct()
 {
     parent::__destruct();
 }
예제 #8
0
     $arr = array();
     $arr['name'] = "BS";
     $arr['value'] = "BS";
     $arr['selected'] = $type == "BS" ? "selected" : "";
     array_push($types, $arr);
     // CS
     if ($settings->cs_rec_flg != 0) {
         $arr = array();
         $arr['name'] = "CS";
         $arr['value'] = "CS";
         $arr['selected'] = $type == "CS" ? "selected" : "";
         array_push($types, $arr);
     }
 }
 $k_station_name = "";
 $crecs = DBRecord::createRecords(CHANNEL_TBL);
 $stations = array();
 $stations[0]['id'] = 0;
 $stations[0]['name'] = "すべて";
 $stations[0]['selected'] = !$station ? "selected" : "";
 foreach ($crecs as $c) {
     $arr = array();
     $arr['id'] = $c->id;
     $arr['name'] = $c->name;
     $arr['selected'] = $station == $c->id ? "selected" : "";
     if ($station == $c->id) {
         $k_station_name = $c->name;
     }
     array_push($stations, $arr);
 }
 $weekofdays["{$weekofday}"]["selected"] = "selected";
예제 #9
0
 public function __get($prop)
 {
     # allow id
     if ($prop == 'id') {
         return $this->get_id();
     }
     # first check in data
     if (isset($this->data[$prop])) {
         $val = $this->data[$prop];
         return $this->getters($prop, $val);
     }
     # then the to_one's
     # if the connection exists
     if ($this->has_relationship($prop, 'to-one')) {
         if (isset($this->to_one_obj[$prop])) {
             $this->to_one_obj[$prop]->include = $this->include;
             $this->to_one_obj[$prop]->load();
             return $this->getters($prop, $this->to_one_obj[$prop]);
         } else {
             if (array_key_exists($prop . '_id', $this->data) && !empty($this->data[$prop . '_id'])) {
                 $this->to_one_obj[$prop] = new $this->to_one[$prop]['class']();
                 $this->to_one_obj[$prop]->set_id($this->data[$prop . '_id']);
                 $this->to_one_obj[$prop]->include = $this->include;
                 $this->to_one_obj[$prop]->load();
                 return $this->getters($prop, $this->to_one_obj[$prop]);
             }
         }
     }
     # then try the to_manys
     # if the connection exists
     if ($this->has_relationship($prop, 'to-many')) {
         # TODO: Maybe this array making can be replaced by a to_many collection class
         if (array_key_exists($prop, $this->to_many_obj) && !empty($this->to_many_obj[$prop])) {
             $out = array();
             foreach ($this->to_many_obj[$prop] as $obj) {
                 $out[] = $obj;
             }
             return $this->getters($prop, $out);
         } else {
             // TODO: see about this include stuff
             # if it's actually a habtm, load accordingly
             if ($this->has_relationship($prop, 'habtm')) {
                 $other_table = $this->habtm[$prop]['other_table'];
                 $table = $this->habtm[$prop]['table'];
                 $props = DBRecord::find_sql("SELECT * from `{$other_table}` LEFT JOIN `{$table}` ON `{$table}`.{$other_table}_id=`{$other_table}`.id WHERE `{$table}`." . $this->get_table() . "_id = '" . $this->get_id() . "'", array('class' => $this->habtm[$prop]['class'], 'include' => $this->include));
             } else {
                 $props = DBRecord::find_by($this->get_table() . '_id', $this->get_id(), array('class' => $this->to_many[$prop]['class'], 'include' => $this->include));
             }
             # tmobj is indexed by id, until tmcollection
             // TODO: another point for a to-many collection
             $a = $props->to_a(false);
             $this->to_many_obj[$prop] = array();
             foreach ($a as $k => $v) {
                 $this->to_many_obj[$prop][$v->get_id()] = $v;
             }
             return $this->getters($prop, $a);
         }
     }
     return $this->getters($prop, false);
 }
예제 #10
0
파일: api.php 프로젝트: ha1t/epgrec
 public function reservationForm()
 {
     require_once INSTALL_PATH . '/DBRecord.class.php';
     if (!isset($_GET['program_id'])) {
         exit('Error: 番組IDが指定されていません');
     }
     $program_id = $_GET['program_id'];
     try {
         $prec = new DBRecord(PROGRAM_TBL, "id", $program_id);
         sscanf($prec->starttime, "%4d-%2d-%2d %2d:%2d:%2d", $syear, $smonth, $sday, $shour, $smin, $ssec);
         sscanf($prec->endtime, "%4d-%2d-%2d %2d:%2d:%2d", $eyear, $emonth, $eday, $ehour, $emin, $esec);
         $crecs = DBRecord::createRecords(CATEGORY_TBL);
         $cats = array();
         foreach ($crecs as $crec) {
             $cat = array();
             $cat['id'] = $crec->id;
             $cat['name'] = $crec->name_jp;
             $cat['selected'] = $prec->category_id == $cat['id'] ? "selected" : "";
             array_push($cats, $cat);
         }
         $smarty = new Smarty();
         $smarty->template_dir = dirname(dirname(__FILE__)) . '/templates/';
         $smarty->compile_dir = dirname(dirname(__FILE__)) . '/templates_c/';
         $smarty->assign("syear", $syear);
         $smarty->assign("smonth", $smonth);
         $smarty->assign("sday", $sday);
         $smarty->assign("shour", $shour);
         $smarty->assign("smin", $smin);
         $smarty->assign("eyear", $eyear);
         $smarty->assign("emonth", $emonth);
         $smarty->assign("eday", $eday);
         $smarty->assign("ehour", $ehour);
         $smarty->assign("emin", $emin);
         $smarty->assign("type", $prec->type);
         $smarty->assign("channel", $prec->channel);
         $smarty->assign("channel_id", $prec->channel_id);
         $smarty->assign("record_mode", $RECORD_MODE);
         $smarty->assign("title", $prec->title);
         $smarty->assign("description", $prec->description);
         $smarty->assign("cats", $cats);
         $smarty->assign("program_id", $prec->id);
         $smarty->display("reservationform.html");
     } catch (Exception $e) {
         exit("Error:" . $e->getMessage());
     }
 }
예제 #11
0
function storeProgram($type, $xmlfile)
{
    global $BS_CHANNEL_MAP, $GR_CHANNEL_MAP, $CS_CHANNEL_MAP;
    // チャンネルマップファイルの準備
    $map = array();
    if ($type == "BS") {
        $map = $BS_CHANNEL_MAP;
    } else {
        if ($type == "GR") {
            $map = $GR_CHANNEL_MAP;
        } else {
            if ($type == "CS") {
                $map = $CS_CHANNEL_MAP;
            }
        }
    }
    // XML parse
    $xml = @simplexml_load_file($xmlfile);
    if ($xml === false) {
        return;
        // XMLが読み取れないなら何もしない
    }
    // channel抽出
    foreach ($xml->channel as $ch) {
        $disc = $ch['id'];
        try {
            // チャンネルデータを探す
            $num = DBRecord::countRecords(CHANNEL_TBL, "WHERE channel_disc = '" . $disc . "'");
            if ($num == 0) {
                // チャンネルデータがないなら新規作成
                $rec = new DBRecord(CHANNEL_TBL);
                $rec->type = $type;
                $rec->channel = $map["{$disc}"];
                $rec->channel_disc = $disc;
                $rec->name = $ch->{'display-name'};
            } else {
                // 存在した場合も、とりあえずチャンネル名は更新する
                $rec = new DBRecord(CHANNEL_TBL, "channel_disc", $disc);
                $rec->name = $ch->{'display-name'};
            }
        } catch (Exception $e) {
            // 無視
        }
    }
    // channel 終了
    // programme 取得
    foreach ($xml->programme as $program) {
        $channel_disc = $program['channel'];
        $channel = $map["{$channel_disc}"];
        $starttime = str_replace(" +0900", '', $program['start']);
        $endtime = str_replace(" +0900", '', $program['stop']);
        $title = $program->title;
        $desc = $program->desc;
        $cat_ja = "";
        $cat_en = "";
        foreach ($program->category as $cat) {
            if ($cat['lang'] == "ja_JP") {
                $cat_ja = $cat;
            }
            if ($cat['lang'] == "en") {
                $cat_en = $cat;
            }
        }
        $program_disc = md5($channel_disc . $starttime . $endtime);
        // printf( "%s %s %s %s %s %s %s \n", $program_disc, $channel, $starttime, $endtime, $title, $desc, $cat_ja );
        try {
            // カテゴリを処理する
            $category_disc = md5($cat_ja . $cat_en);
            $num = DBRecord::countRecords(CATEGORY_TBL, "WHERE category_disc = '" . $category_disc . "'");
            $cat_rec = null;
            if ($num == 0) {
                // 新規カテゴリの追加
                $cat_rec = new DBRecord(CATEGORY_TBL);
                $cat_rec->name_jp = $cat_ja;
                $cat_rec->name_en = $cat_en;
                $cat_rec->category_disc = $category_disc;
            } else {
                $cat_rec = new DBRecord(CATEGORY_TBL, "category_disc", $category_disc);
            }
            //
            $channel_rec = new DBRecord(CHANNEL_TBL, "channel_disc", $channel_disc);
            $num = DBRecord::countRecords(PROGRAM_TBL, "WHERE program_disc = '" . $program_disc . "'");
            if ($num == 0) {
                // 新規番組
                // 重複チェック 同時間帯にある番組
                $options = "WHERE channel_disc = '" . $channel_disc . "' " . "AND starttime < '" . $endtime . "' AND endtime > '" . $starttime . "'";
                $battings = DBRecord::countRecords(PROGRAM_TBL, $options);
                if ($battings > 0) {
                    // 重複発生=おそらく放映時間の変更
                    $records = DBRecord::createRecords(PROGRAM_TBL, $options);
                    foreach ($records as $rec) {
                        // 自動録画予約された番組は放映時間変更と同時にいったん削除する
                        try {
                            $reserve = new DBRecord(RESERVE_TBL, "program_id", $rec->id);
                            if ($reserve->autorec) {
                                Reservation::cancel($reserve->id);
                            }
                        } catch (Exception $e) {
                            //無視
                        }
                        // 番組削除
                        $rec->delete();
                    }
                }
                // //
                $rec = new DBRecord(PROGRAM_TBL);
                $rec->channel_disc = $channel_disc;
                $rec->channel_id = $channel_rec->id;
                $rec->type = $type;
                $rec->channel = $channel_rec->channel;
                $rec->title = $title;
                $rec->description = $desc;
                $rec->category_id = $cat_rec->id;
                $rec->starttime = $starttime;
                $rec->endtime = $endtime;
                $rec->program_disc = $program_disc;
            } else {
                // 番組内容更新
                $rec = new DBRecord(PROGRAM_TBL, "program_disc", $program_disc);
                $rec->title = $title;
                $rec->description = $desc;
                $rec->category_id = $cat_rec->id;
            }
        } catch (Exception $e) {
            exit($e->getMessage());
        }
    }
}
예제 #12
0
 private function fetchColumns()
 {
     $result = mysql_query("SHOW COLUMNS FROM " . $this->tableName);
     $this->columns = array();
     $this->camelColumns = array();
     while ($row = mysql_fetch_array($result)) {
         $this->columns[$row['Field']] = $row;
         $camelColumn = DBRecord::camelCase($row['Field']);
         $this->camelColumns[$camelColumn] = $row;
     }
 }
예제 #13
0
파일: getepg.php 프로젝트: sushi-k/epgrec
        if ($num == 0 && check_file($temp_xml_cs2)) {
            $cmdline = "CHANNEL=" . CS2_EPG_CHANNEL . " DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=" . $settings->temp_data . " " . DO_RECORD . " >/dev/null 2>&1";
            exec($cmdline);
            $cmdline = $settings->epgdump . " /CS " . $settings->temp_data . " " . $temp_xml_cs2;
            exec($cmdline);
            $cmdline = INSTALL_PATH . "/storeProgram.php CS " . $temp_xml_cs2 . " >/dev/null 2>&1 &";
            exec($cmdline);
            if (file_exists($settings->temp_data)) {
                @unlink($settings->temp_data);
            }
        }
    }
}
// 地上波を処理する
if ($settings->gr_tuners != 0) {
    foreach ($GR_CHANNEL_MAP as $key => $value) {
        // 録画重複チェック
        $num = DBRecord::countRecords(RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')");
        if ($num == 0 && check_file($temp_xml_gr . $value . "")) {
            $cmdline = "CHANNEL=" . $value . " DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=" . $settings->temp_data . " " . DO_RECORD . " >/dev/null 2>&1";
            exec($cmdline);
            $cmdline = $settings->epgdump . " " . $key . " " . $settings->temp_data . " " . $temp_xml_gr . $value . "";
            exec($cmdline);
            $cmdline = INSTALL_PATH . "/storeProgram.php GR " . $temp_xml_gr . $value . " >/dev/null 2>&1 &";
            exec($cmdline);
            if (file_exists($settings->temp_data)) {
                @unlink($settings->temp_data);
            }
        }
    }
}
예제 #14
0
 protected function test_uniqueness_of($prop, $msg)
 {
     if (!array_key_exists($prop, $this->data)) {
         return true;
     }
     $testval = is_object($this->data[$prop]) ? $this->data[$prop]->__toString() : $this->data[$prop];
     $where = $this->parent->get_table() . ".{$prop} = '" . $this->parent->escape_string($testval) . "'";
     if ($this->parent->get_id()) {
         $where .= " AND " . $this->parent->get_table() . ".id <> " . $this->parent->get_id();
     }
     $r = DBRecord::find_where($where, array('class' => $this->parent_class));
     // TODO: changed this to use count, watch it
     if (count($r) > 0) {
         $this->add_error(human_name($prop), $msg, VALIDATION_UNIQUE);
         return false;
     }
     return true;
 }
예제 #15
0
#!/usr/bin/php
<?php 
include_once 'config.php';
include_once INSTALL_PATH . '/DBRecord.class.php';
include_once INSTALL_PATH . '/reclib.php';
include_once INSTALL_PATH . '/Settings.class.php';
$settings = Settings::factory();
try {
    $recs = DBRecord::createRecords(RESERVE_TBL);
    // DB接続
    $dbh = mysql_connect($settings->db_host, $settings->db_user, $settings->db_pass);
    if ($dbh === false) {
        exit("mysql connection fail");
    }
    $sqlstr = "use " . $settings->db_name;
    mysql_query($sqlstr);
    $sqlstr = "set NAME utf8";
    mysql_query($sqlstr);
    foreach ($recs as $rec) {
        $title = mysql_real_escape_string($rec->title) . "(" . date("Y/m/d", toTimestamp($rec->starttime)) . ")";
        $sqlstr = "update mt_cds_object set metadata='dc:description=" . mysql_real_escape_string($rec->description) . "&epgrec:id=" . $rec->id . "' where dc_title='" . $rec->path . "'";
        mysql_query($sqlstr);
        $sqlstr = "update mt_cds_object set dc_title='" . $title . "' where dc_title='" . $rec->path . "'";
        mysql_query($sqlstr);
    }
} catch (Exception $e) {
    exit($e->getMessage());
}
예제 #16
0
<?php

include_once 'config.php';
include_once INSTALL_PATH . '/DBRecord.class.php';
include_once INSTALL_PATH . '/Smarty/Smarty.class.php';
try {
    $rvs = DBRecord::createRecords(RESERVE_TBL, "WHERE complete='0' ORDER BY starttime ASC");
    $reservations = array();
    foreach ($rvs as $r) {
        $cat = new DBRecord(CATEGORY_TBL, "id", $r->category_id);
        $arr = array();
        $arr['id'] = $r->id;
        $arr['type'] = $r->type;
        $arr['channel'] = $r->channel;
        $arr['starttime'] = $r->starttime;
        $arr['endtime'] = $r->endtime;
        $arr['mode'] = $RECORD_MODE[$r->mode]['name'];
        $arr['title'] = $r->title;
        $arr['description'] = $r->description;
        $arr['cat'] = $cat->name_en;
        $arr['autorec'] = $r->autorec;
        array_push($reservations, $arr);
    }
    $smarty = new Smarty();
    $smarty->assign("sitetitle", "録画予約一覧");
    $smarty->assign("reservations", $reservations);
    $smarty->display("reservationTable.html");
} catch (exception $e) {
    exit($e->getMessage());
}