Пример #1
0
 public function sendSms($telephone = '', $content = '', $is_meeting = 0)
 {
     if (!$telephone || !$content) {
         return false;
     }
     $config = $this->settings['sms_code'];
     if ($is_meeting) {
         $config['sign'] = '【厚建软件】';
         $config['subcode'] = '';
     }
     $message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . "<message>" . "<account>" . $config['account'] . "</account>" . "<password>" . md5($config['password']) . "</password>" . "<msgid></msgid>" . "<phones>" . $telephone . "</phones>" . "<content>" . $content . "</content>" . "<sign>" . $config['sign'] . "</sign>" . "<subcode>" . $config['subcode'] . "</subcode>" . "<sendtime></sendtime>" . "</message>";
     $params = array('message' => $message);
     $data = http_build_query($params);
     $context = array('http' => array('method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => $data));
     $reponse = file_get_contents($config['request_send_url'], false, stream_context_create($context));
     if ($reponse) {
         $ret = xml2Array($reponse);
         if ($ret && is_array($ret) && !$ret['result']) {
             return true;
         }
         return false;
     } else {
         return false;
     }
 }
Пример #2
0
 public function detail($id)
 {
     $arr = array();
     $xml = '<?xml version="1.0" encoding="utf-8"?>';
     $xml .= '<paras>';
     $xml .= '<IdentityGuid>Epoint_WebSerivce_**##0601</IdentityGuid>';
     $xml .= '<infoid>' . $id . '</infoid>';
     $xml .= '</paras>';
     $cilentOptions = array('trace' => true, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE);
     $client = new SoapClient(WEB_URL, $cilentOptions);
     $ret_str = $client->SelectBMZX(array('xmlWebInfo' => $xml));
     //var_dump($ret_str);exit();
     $ret_str = $ret_str->SelectBMZXResult;
     $ret_str = xml2Array($ret_str);
     //hg_pre($ret_str);exit();
     if (!$ret_str['DATA']['ReturnInfo']['Status']) {
         return $arr;
     }
     $data = $ret_str['DATA']['UserArea'];
     //hg_pre($data);exit();
     $arr['id'] = $data['infoid'];
     $arr['create_time'] = strtotime($data['infodate']);
     $arr['title'] = $data['title'];
     $arr['content'] = str_replace("&nbsp;", "", strip_tags($data['InfoContent']));
     $arr['click_times'] = $data['ClickTimes'];
     //点击次数
     //hg_pre($arr);exit();
     return $arr;
 }
Пример #3
0
 public function show()
 {
     if (!$this->input['user_number']) {
         $this->errorOutput(NO_USER_NUMBER);
         //没有户号
     }
     if (!$this->input['month']) {
         $this->errorOutput(NO_QUERY_MONTH);
         //没有查询最近几个月
     } else {
         if (intval($this->input['month']) > 12 || intval($this->input['month']) < 0) {
             $this->errorOutput(MONTH_ERROR);
         }
     }
     $data = $this->water->query($this->input['user_number'], $this->input['month']);
     if (!$data) {
         $this->errorOutput(NO_DATA);
     }
     $data_arr = xml2Array($data);
     if (!$data_arr) {
         $this->errorOutput(DATA_ERROR);
     }
     foreach ($data_arr['record'] as $k => $v) {
         if ($v['status'] == '已销') {
             $data_arr['record'][$k]['state'] = 1;
         } else {
             $data_arr['record'][$k]['state'] = 0;
         }
     }
     $this->addItem($data_arr);
     $this->output();
 }
Пример #4
0
function proccessSiteMapUrl($url)
{
    $siteMapXml = file_get_contents($url);
    $siteMapXmlArray = xml2Array($siteMapXml);
    if (isset($siteMapXmlArray['sitemapindex'])) {
        proccessSiteMapIndex($siteMapXmlArray);
    } elseif (isset($siteMapXmlArray['urlset'])) {
        proccessSiteMap($siteMapXmlArray);
    }
}
Пример #5
0
 public function get_version($url)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 2);
     $ret = curl_exec($ch);
     curl_close($ch);
     $ret = xml2Array($ret);
     return $ret;
 }
Пример #6
0
 public function get_version($url)
 {
     //$url = 'http://10.0.1.58:8089/control/recordserver/task?action=GET_VERSION';
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 2);
     $ret = curl_exec($ch);
     curl_close($ch);
     $ret = xml2Array($ret);
     return $ret;
 }
Пример #7
0
 function cn_com_weather_update($city = array(), $weather_source_id = 0, $userinfo = array(), $cityEngName = array(), $cityCode = array(), $update = true)
 {
     $weather_info = array();
     if (!$weather_source_id || empty($city) || empty($cityEngName)) {
         return $weather_info;
     }
     //hg_pre($cityCode);exit();
     foreach ($city as $key => $val) {
         $url = 'http://flash.weather.com.cn/wmaps/xml/' . $cityEngName[$val] . '.xml';
         $rss = @simplexml_load_file($url);
         if (!$rss) {
             continue;
         }
         $temp[$val] = xml2Array($url);
     }
     //hg_pre($temp);exit();
     $return = array();
     if (!empty($temp) && $temp && is_array($temp)) {
         foreach ($temp as $city_id => $val) {
             //hg_pre($val['city']);exit();
             $data = array();
             $forcast = array();
             foreach ($val['city'] as $kk => $vv) {
                 if ($vv['url'] == $cityCode[$city_id]) {
                     $extra = array('humidity' => $vv['humidity']);
                     $data = array('id' => $city_id, 'source_id' => intval($weather_source_id), 'w_date' => date('Y-m-d', TIMENOW), 'w_time' => $vv['time'], 'temperature' => $vv['temNow'], 'wind_direction' => $vv['windDir'], 'wind_level' => $vv['windPower'], 'extra' => addslashes(serialize($extra)), 'user_id' => $userinfo['user_id'], 'user_name' => $userinfo['user_name'], 'ip' => hg_getip());
                     $forcast = array('report' => $vv['stateDetailed'], 'fx' => $vv['windDir'], 'fl' => $vv['windState'], 'temp' => $vv['tem1'] . '℃~' . $vv['tem2'] . '℃', 'sd' => $vv['humidity'], 'time' => $vv['time']);
                 }
             }
             if (empty($data)) {
                 //hg_pre($val['city'][0]);exit();
             }
             if (empty($data)) {
                 $extra = array('humidity' => $val['city'][0]['humidity']);
                 $data = array('id' => $city_id, 'source_id' => intval($weather_source_id), 'w_date' => date('Y-m-d', TIMENOW), 'w_time' => $val['city'][0]['time'], 'temperature' => $val['city'][0]['temNow'], 'wind_direction' => $val['city'][0]['windDir'], 'wind_level' => $val['city'][0]['windPower'], 'extra' => addslashes(serialize($extra)), 'user_id' => $userinfo['user_id'], 'user_name' => $userinfo['user_name'], 'ip' => hg_getip());
                 $forcast = array('report' => $val['city'][0]['stateDetailed'], 'fx' => $val['city'][0]['windDir'], 'fl' => $val['city'][0]['windState'], 'temp' => $val['city'][0]['tem1'] . '℃~' . $val['city'][0]['tem2'] . '℃', 'sd' => $val['city'][0]['humidity'], 'time' => $val['city'][0]['time']);
             }
             $return[$city_id] = $data;
             $ret = $this->pubWeather->storedIntoDB($data, 'weather_information');
             $this->update_day_weather($city_id, $data);
             $this->update_forcast_weather($city_id, $forcast);
         }
     }
     return $return;
 }
Пример #8
0
 public function detail($id)
 {
     $arr = array();
     $xml = '<?xml version="1.0" encoding="utf-8"?>';
     $xml .= '<paras>';
     $xml .= '<IdentityGuid>Epoint_WebSerivce_**##0601</IdentityGuid>';
     $xml .= '<CaseGuid>' . $id . '</CaseGuid>';
     $xml .= '</paras>';
     $cilentOptions = array('trace' => true, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE);
     $client = new SoapClient(WEB_URL, $cilentOptions);
     $ret_str = $client->SelectCaseInfoDetail_GGFW(array('xmlCaseInfo' => $xml));
     //var_dump($ret_str);exit();
     $ret_str = $ret_str->SelectCaseInfoDetail_GGFWResult;
     $ret_str = xml2Array($ret_str);
     //hg_pre($ret_str);exit();
     if (!$ret_str['DATA']['ReturnInfo']['Status']) {
         return $arr;
     }
     $data = $ret_str['DATA']['UserArea'];
     //hg_pre($data);exit();
     $arr['id'] = $data['CaseGuid'];
     $arr['case_serial'] = $data['CaseSerial'];
     //编号
     $arr['create_time'] = $data['RequestDate'] ? strtotime($data['RequestDate']) : $data['RequestDate'];
     $arr['tel'] = $data['RequestNumber'];
     $arr['user_name'] = $data['RequestPerson'];
     $arr['email'] = $data['Email'];
     $arr['address'] = $data['Address'];
     $arr['area'] = $this->settings['service_area'][$data['RequestAddress']];
     $arr['title'] = $data['RequestTitle'];
     $arr['content'] = cdata($data['Description']);
     $arr['note'] = $data['RequestNote'];
     //备注;
     $arr['case_status'] = $this->settings['service_case_status'][$data['CaseStatus']];
     //工单状态
     $arr['case_type'] = $this->settings['service_case_type'][$data['CaseType']];
     //工单类型
     $arr['answer_date'] = $data['AnswerDate'] ? strtotime($data['AnswerDate']) : $data['AnswerDate'];
     $arr['answer_content'] = cdata($data['AnswerContent']);
     $arr['manyidu'] = $data['ManYiDu'];
     return $arr;
 }
Пример #9
0
function xml2Array($xml, $root = true)
{
    if (is_string($xml)) {
        $xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
    }
    if (!$xml->children()) {
        return (string) $xml;
    }
    $array = array();
    foreach ($xml->children() as $element => $node) {
        $totalElement = count($xml->{$element});
        if (!isset($array[$element])) {
            $array[$element] = "";
        }
        // Has attributes
        if ($attributes = $node->attributes()) {
            $data = array('value' => count($node) > 0 ? xml2Array($node, false) : (string) $node);
            foreach ($attributes as $attr => $value) {
                $data['@' . $attr] = (string) $value;
            }
            if ($totalElement > 1) {
                $array[$element][] = $data;
            } else {
                $array[$element] = $data;
            }
            // Just a value
        } else {
            if ($totalElement > 1) {
                $array[$element][] = xml2Array($node, false);
            } else {
                $array[$element] = xml2Array($node, false);
            }
        }
    }
    if ($root) {
        return array($xml->getName() => $array);
    } else {
        return $array;
    }
}
Пример #10
0
 function update_day()
 {
     if (!$this->input['channel_id']) {
         $this->errorOutput("未传入频道ID");
     }
     if (!$this->input['dates']) {
         $this->errorOutput("未传入更新日期");
     }
     /*
     $sql = "select r.start_time,r.end_time,r.channel_id,r.week_num,p.item from " . DB_PREFIX . "program_record p left join " . DB_PREFIX . "program_record_relation r on p.id = r.record_id where r.channel_id=" . $this->input['channel_id'] . " and r.week_num=".date('N',strtotime($this->input['dates']));
     		$q = $this->db->query($sql);
     				$record = array();
     		while($r = $this->db->fetch_array($q))
     		{
     			$record[] = $r['start_time'] . '-' . $r['end_time'] . '-' . $r['item'];
     		}
     */
     include_once ROOT_PATH . 'lib/class/live.class.php';
     $obj_live = new live();
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     $this->curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
     $arr = array('color' => $this->input['color'], 'checke' => $this->input['checke'], 'start_time' => $this->input['start_time'], 'theme' => $this->input['theme'], 'end_time' => $this->input['end_time'], 'item' => $this->input['item'], 'new' => $this->input['new'], 'plan' => $this->input['plan'], 'plan_source' => $this->input['plan_source'], 'program_source' => $this->input['program_source']);
     foreach ($arr as $key => $value) {
         if (empty($value)) {
             unset($arr[$key]);
         }
     }
     $dates = urldecode($this->input['dates']);
     if (empty($arr)) {
         $sql = "SELECT * FROM " . DB_PREFIX . "program WHERE channel_id = " . $this->input['channel_id'] . " and dates='" . $dates . "'";
         $q = $this->db->query($sql);
         $tmp_record_id = $tmp_space = '';
         while ($row = $this->db->fetch_array($q)) {
             if ($row['record_id']) {
                 $tmp_record_id .= $tmp_space . $row['record_id'];
                 $tmp_space = ',';
             }
         }
         if ($tmp_record_id) {
             $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE id IN (" . $tmp_record_id . ")";
             $q = $this->db->query($sql);
             $tmp_record_id_plan = $tmp_record_id_program = 0;
             $space_plan = $space_program = '';
             while ($row = $this->db->fetch_array($q)) {
                 if ($row['plan_id']) {
                     $tmp_record_id_plan .= $space_plan . $row['id'];
                     $space_plan = ',';
                 } else {
                     $tmp_record_id_program .= $space_program . $row['id'];
                     $space_program = ',';
                 }
             }
             if ($tmp_record_id_program) {
                 $obj_live->delete_record($tmp_record_id_program);
             }
             if ($tmp_record_id_plan) {
                 $sql = "UPDATE " . DB_PREFIX . "program_record SET program_id=0 WHERE id IN(" . $tmp_record_id_plan . ")";
                 $this->db->query($sql);
             }
         }
         $sql = "DELETE FROM " . DB_PREFIX . "program WHERE channel_id = " . $this->input['channel_id'] . " and dates='" . $dates . "'";
         $this->db->query($sql);
         $program_plan = $this->getPlan($this->input['channel_id'], $dates);
         $program = array();
         $start = strtotime($dates . " 00:00:00");
         $end = strtotime($dates . " 23:59:59");
         if (empty($program_plan)) {
             $program[] = $this->getInfo($start, strtotime($dates . " 08:00:00"), $dates, $this->input['channel_id'], 1, 0);
             $program[] = $this->getInfo(strtotime($dates . " 08:00:00"), $end, $dates, $this->input['channel_id']);
         } else {
             $com_time = 0;
             foreach ($program_plan as $k => $v) {
                 if (!$com_time && $v['start_time'] > $start) {
                     $program[] = $this->getInfo($start, $v['start_time'], $dates, $this->input['channel_id']);
                 }
                 if ($com_time && $com_time != $v['start_time']) {
                     $program[] = $this->getInfo($com_time, $v['start_time'], $dates, $this->input['channel_id']);
                 }
                 $v['start'] = date("H:i", $v['start_time']);
                 $v['end'] = date("H:i", $v['start_time'] + $v['toff']);
                 if ($v['start_time'] <= TIMENOW) {
                     $v['outdate'] = 1;
                 } else {
                     $v['outdate'] = 0;
                 }
                 $com_time = $v['start_time'] + $v['toff'];
                 $program[] = $v;
             }
             if ($com_time && $com_time < $end) {
                 $program[] = $this->getInfo($com_time, $end, $dates, $this->input['channel_id']);
             }
         }
         //	file_put_contents('../cache/2.php',var_export($program,1));
         $this->addItem($program);
         $this->output();
     }
     $prev_end = 0;
     foreach ($arr['start_time'] as $k => $v) {
         $start_this = strtotime(urldecode($dates . " " . $v));
         $end_this = strtotime(urldecode($dates . " " . $arr['end_time'][$k]));
         if ($start_this >= $end_this) {
             $this->errorOutput($v . '~' . urldecode($arr['end_time'][$k]) . "的开始时间大于等于结束时间");
         }
         if ($prev_end && $prev_end > $start_this) {
             $this->errorOutput($start_this . "的上一个节目的时间有误");
         }
         $prev_end = $end_this;
     }
     $ids = $spa = '';
     foreach ($arr['color'] as $key => $value) {
         $pid = $key;
         if ($arr['checke'][$pid]) {
             $info = array('id' => $pid, 'color' => urldecode($value), 'start_time' => strtotime(urldecode($dates . " " . $arr['start_time'][$key])), 'theme' => rawurldecode($arr['theme'][$key]), 'toff' => strtotime(urldecode($dates . " " . $arr['end_time'][$key])) - strtotime(urldecode($dates . " " . $arr['start_time'][$key])), 'item' => intval($arr['item'][$key]), 'new' => urldecode($arr['new'][$key]), 'plan' => intval($arr['plan'][$key]), 'plan_source' => intval($arr['plan_source'][$key]), 'program_source' => intval($arr['program_source'][$key]));
             if ($info['new']) {
                 $creates = array('channel_id' => $this->input['channel_id'], 'start_time' => $info['start_time'], 'toff' => $info['toff'], 'theme' => rawurldecode($arr['theme'][$key]), 'type_id' => 1, 'weeks' => date("W", $info['start_time']), 'dates' => date("Y-m-d", $info['start_time']), 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'is_show' => 1);
                 $sql = "INSERT INTO " . DB_PREFIX . "program SET ";
                 $space = "";
                 foreach ($creates as $k => $v) {
                     $sql .= $space . $k . "=" . "'" . $v . "'";
                     $space = ",";
                 }
                 $this->db->query($sql);
                 $info['id'] = $this->db->insert_id();
                 $pid = $info['id'];
                 if ($info['item'] > 0) {
                     $record_create = array('title' => $info['theme'], 'channel_id' => $this->input['channel_id'], 'program_id' => $info['id'], 'start_time' => $info['start_time'], 'toff' => $info['toff'], 'item' => $info['item'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip());
                     if ($record_create['start_time'] < TIMENOW) {
                         $record_create['is_out'] = 1;
                     }
                     if ($info['plan']) {
                         $sql = "SELECT id FROM " . DB_PREFIX . "program_record WHERE plan_id=" . $info['plan'];
                         $tmp_plan_record = $this->db->query_first($sql);
                         if ($info['program_source'] == 2) {
                             $createsql = "INSERT INTO " . DB_PREFIX . "program_record SET ";
                             $space = "";
                             foreach ($record_create as $k => $v) {
                                 $createsql .= $space . $k . "=" . "'" . $v . "'";
                                 $space = ",";
                             }
                             $this->db->query($createsql);
                             $record_id = $this->db->insert_id();
                             $this->insert_relation($record_create['channel_id'], $record_id, $record_create['start_time'], $record_create['toff'], 0);
                             $sql = "UPDATE " . DB_PREFIX . "program SET record_id='" . $record_id . "' WHERE id=" . $info['id'];
                             $this->db->query($sql);
                         } else {
                             if (!empty($tmp_plan_record)) {
                                 $sql = "UPDATE " . DB_PREFIX . "program_record SET program_id=" . $info['id'] . " WHERE plan_id=" . $info['plan'];
                                 $this->db->query($sql);
                                 $sql = "UPDATE " . DB_PREFIX . "program SET record_id='" . $tmp_plan_record['id'] . "' WHERE id=" . $info['id'];
                                 $this->db->query($sql);
                             } else {
                             }
                         }
                     } else {
                         //不是计划,而且有录制,说明肯定创建单天录制
                         $createsql = "INSERT INTO " . DB_PREFIX . "program_record SET ";
                         $space = "";
                         foreach ($record_create as $k => $v) {
                             $createsql .= $space . $k . "=" . "'" . $v . "'";
                             $space = ",";
                         }
                         $this->db->query($createsql);
                         $record_id = $this->db->insert_id();
                         $this->insert_relation($record_create['channel_id'], $record_id, $record_create['start_time'], $record_create['toff'], 0);
                         $sql = "UPDATE " . DB_PREFIX . "program SET record_id='" . $record_id . "' WHERE id=" . $info['id'];
                         $this->db->query($sql);
                     }
                 }
             } else {
                 $sql = "UPDATE " . DB_PREFIX . "program SET color='" . $info['color'] . "',start_time=" . $info['start_time'] . ",theme='" . $info['theme'] . "',toff=" . $info['toff'] . " where id=" . $info['id'];
                 $this->db->query($sql);
                 if ($info['item'] > 0) {
                     $record_create = array('title' => $info['theme'], 'channel_id' => $this->input['channel_id'], 'program_id' => $info['id'], 'start_time' => $info['start_time'], 'toff' => $info['toff'], 'item' => $info['item'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip());
                     $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE program_id=" . $info['id'];
                     $tmp_senc = $this->db->query_first($sql);
                     if (empty($tmp_senc)) {
                         $createsql = "INSERT INTO " . DB_PREFIX . "program_record SET ";
                         $space = "";
                         foreach ($record_create as $k => $v) {
                             $createsql .= $space . $k . "=" . "'" . $v . "'";
                             $space = ",";
                         }
                         $this->db->query($createsql);
                         $record_id = $this->db->insert_id();
                         $this->insert_relation($record_create['channel_id'], $record_id, $record_create['start_time'], $record_create['toff'], 0);
                         $sql = "UPDATE " . DB_PREFIX . "program SET record_id='" . $record_id . "' WHERE id=" . $info['id'];
                         $this->db->query($sql);
                     } else {
                         $record_update = array('title' => $info['theme'], 'start_time' => $info['start_time'], 'toff' => $info['toff'], 'item' => $info['item'], 'update_time' => TIMENOW);
                         $sql = "SELECT id,log_id,conid FROM " . DB_PREFIX . "program_queue WHERE id=" . $tmp_senc['conid'];
                         $sen = $this->db->query_first($sql);
                         if ($sen) {
                             $this->curl->mPostContentType('string');
                             $this->curl->setSubmitType('get');
                             $this->curl->setReturnFormat('json');
                             $this->curl->initPostData();
                             if (!defined('IS_WOZA') || !IS_WOZA) {
                                 $this->curl->addRequestData('action', 'DELETE');
                             } else {
                                 $this->curl->addRequestData('action', 'delete');
                             }
                             $this->curl->addRequestData('id', $sen['conid']);
                             $record_xml = $this->curl->request('');
                             $record_array = xml2Array($record_xml);
                             if ($record_array['result']) {
                                 $sql = "DELETE FROM " . DB_PREFIX . "program_record_log WHERE id IN (" . $sen['log_id'] . ")";
                                 $this->db->query($sql);
                                 $sql = "DELETE FROM " . DB_PREFIX . "program_queue WHERE id=" . $sen['id'];
                                 $this->db->query($sql);
                             }
                         }
                         if (empty($tmp_senc['week_day'])) {
                             if ($record_update['start_time'] <= TIMENOW) {
                                 //相当于重置录制
                                 $record_update['is_out'] = 1;
                             }
                             $updatesql = "UPDATE " . DB_PREFIX . "program_record SET ";
                             $space = "";
                             foreach ($record_update as $k => $v) {
                                 $updatesql .= $space . $k . "=" . "'" . $v . "'";
                                 $space = ",";
                             }
                             $updatesql .= " WHERE program_id=" . $info['id'];
                             $this->db->query($updatesql);
                         } else {
                             if ($record_update['start_time'] <= TIMENOW) {
                                 $week_now = date('N', TIMENOW);
                                 $week_num = unserialize($tmp_senc['week_day']);
                                 if (in_array($week_now, $week_num)) {
                                     $dates = date('Y-m-d', TIMENOW);
                                 }
                                 $i = 0;
                                 $next_day = $next_week_day = 0;
                                 foreach ($week_num as $k => $v) {
                                     if (!$i && $v > $week_now) {
                                         $next_day = $v;
                                         $i = 1;
                                     }
                                     if (!$k) {
                                         $next_week_day = $v;
                                     }
                                 }
                                 if (!$next_day) {
                                     $next_day = $next_week_day;
                                 }
                                 $next_week = $next_day - $week_now > 0 ? $next_day - $week_now : $next_day - $week_now + 7;
                                 $dates = date('Y-m-d', TIMENOW + $next_week * 86400);
                                 $record_update['start_time'] = strtotime($dates . ' ' . date('H:i:s', $tmp_senc['start_time']));
                             }
                             $updatesql = "UPDATE " . DB_PREFIX . "program_record SET ";
                             $space = "";
                             foreach ($record_update as $k => $v) {
                                 $updatesql .= $space . $k . "=" . "'" . $v . "'";
                                 $space = ",";
                             }
                             $updatesql .= " WHERE program_id=" . $info['id'];
                             $this->db->query($updatesql);
                         }
                     }
                 } else {
                     $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE program_id=" . $info['id'];
                     $tmp_senc = $this->db->query_first($sql);
                     if (empty($tmp_senc)) {
                         //对录制不做任何操作
                     } else {
                         if ($tmp_senc['plan_id']) {
                             $sql = "UPDATE " . DB_PREFIX . "program_record SET program_id=0 WHERE id=" . $tmp_senc['id'];
                             $this->db->query($sql);
                         } else {
                             $obj_live->delete_record($tmp_senc['id']);
                         }
                         //原本的节目中的录制ID必须更新为0
                         $sql = "UPDATE " . DB_PREFIX . "program SET record_id=0 WHERE id=" . $info['id'];
                         $this->db->query($sql);
                     }
                 }
             }
         }
         $ids .= $spa . $pid;
         $spa = ',';
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "program WHERE channel_id = " . $this->input['channel_id'] . " AND id NOT IN(" . $ids . ") and dates='" . $dates . "'";
     $q = $this->db->query($sql);
     $tmp_record_id = $tmp_space = '';
     while ($row = $this->db->fetch_array($q)) {
         if ($row['record_id']) {
             $tmp_record_id .= $tmp_space . $row['record_id'];
             $tmp_space = ',';
         }
     }
     if ($tmp_record_id) {
         $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE id IN (" . $tmp_record_id . ")";
         $q = $this->db->query($sql);
         $tmp_record_id_plan = $tmp_record_id_program = 0;
         $space_plan = $space_program = '';
         while ($row = $this->db->fetch_array($q)) {
             if ($row['plan_id']) {
                 $tmp_record_id_plan .= $space_plan . $row['id'];
                 $space_plan = ',';
             } else {
                 $tmp_record_id_program .= $space_program . $row['id'];
                 $space_program = ',';
             }
         }
         if ($tmp_record_id_program) {
             $obj_live->delete_record($tmp_record_id_program);
         }
         if ($tmp_record_id_plan) {
             $sql = "UPDATE " . DB_PREFIX . "program_record SET program_id=0 WHERE id IN(" . $tmp_record_id_plan . ")";
             $this->db->query($sql);
         }
     }
     $sql = "DELETE FROM " . DB_PREFIX . "program WHERE channel_id = " . $this->input['channel_id'] . " AND id NOT IN(" . $ids . ") and dates='" . $dates . "'";
     $this->db->query($sql);
     $program = $this->get_program($this->input['channel_id'], $dates);
     //	file_put_contents('../cache/1.php',var_export($program,1));
     $this->addItem($program);
     $this->output();
 }
Пример #11
0
 public function show($condition, $data_limit, $dates = '')
 {
     $sql = "select p.* from " . DB_PREFIX . "program_record p ";
     if ($dates) {
         $sql .= "left join " . DB_PREFIX . "program_record_relation r on r.record_id = p.id ";
     }
     $sql .= " where 1 " . $condition . " ORDER BY p.is_record ASC,p.start_time ASC " . $data_limit;
     $q = $this->db->query($sql);
     $week_day_arr = array('1' => '一', '2' => '二', '3' => '三', '4' => '四', '5' => '五', '6' => '六', '7' => '日');
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $livmedia = new livmedia();
     $sort_name = $livmedia->getAutoItem();
     $conid = $space = "";
     $data = $channel = array();
     while ($row = $this->db->fetch_array($q)) {
         $channel[$row['channel_id']] = $row['channel_id'];
         $conid .= $space . $row['conid'];
         $space = ',';
         $data[] = $row;
     }
     if (!empty($channel)) {
         $channel_ids = implode(',', $channel);
         $channel = array();
         include_once ROOT_PATH . 'lib/class/live.class.php';
         $newLive = new live();
         $channel_tmp = $newLive->getChannelById($channel_ids, -1, 1);
         if (!empty($channel_tmp)) {
             foreach ($channel_tmp as $k => $v) {
                 $channel[$v['id']] = $v;
             }
         }
     }
     $log = array();
     if ($conid) {
         $sql = "SELECT log_id FROM " . DB_PREFIX . "program_queue WHERE id IN(" . $conid . ")";
         $log_id = $space = '';
         $q = $this->db->query($sql);
         while ($row = $this->db->fetch_array($q)) {
             $log_id .= $space . $row['log_id'];
             $space = ',';
         }
         if ($log_id) {
             $sql = "SELECT a.*,q.conid FROM " . DB_PREFIX . "program_record_log a LEFT JOIN " . DB_PREFIX . "program_queue q ON a.id=q.log_id WHERE a.id IN (" . $log_id . ")";
             $q = $this->db->query($sql);
             $log = array();
             while ($row = $this->db->fetch_array($q)) {
                 $log[$row['record_id']] = $row;
             }
         }
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "server_config WHERE 1 AND state=1";
     $q = $this->db->query($sql);
     $server_config = array();
     while ($row = $this->db->fetch_array($q)) {
         $server_config[$row['id']] = $row;
     }
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     foreach ($data as $k => $v) {
         if (empty($channel[$v['channel_id']])) {
             $channel[$v['channel_id']]['name'] = '频道关闭';
         }
         $v['channel'] = $channel[$v['channel_id']]['name'];
         $v['status'] = $channel[$v['channel_id']]['status'];
         $dates = date('Y-m-d', $v['start_time']);
         $channel_id = $v['channel_id'];
         $start_time = $v['start_time'];
         $week_day = unserialize($v['week_day']);
         $v['start_time'] = date('H:i:s', $start_time);
         $v['end_time'] = date('H:i:s', $v['toff'] + $start_time);
         $mins = floor($v['toff'] / 60);
         $sen = $v['toff'] - $mins * 60;
         $v['toff_decode'] = ($mins ? $mins . "'" : '') . ($sen ? $sen . "''" : '');
         $v['dates'] = $dates;
         //$v['w'] = date('w',strtotime($start_time));
         $v['sort_name'] = $sort_name[$v['item']];
         $tmp = $log[$v['id']];
         if (!empty($week_day)) {
             if (count($week_day) == 7) {
                 $v['cycle'] = '每天';
             } else {
                 $spac = '';
                 foreach ($week_day as $kk => $vv) {
                     $v['cycle'] .= $spac . $week_day_arr[$vv];
                     $spac = '&nbsp;|&nbsp;';
                 }
             }
         } else {
             $v['cycle'] = date('Y-m-d', $start_time);
         }
         if ($server_config && $server_config[$v['server_id']]) {
             if ($tmp) {
                 $obj_curl = new curl($server_config[$v['server_id']]['host'] . ':' . $server_config[$v['server_id']]['port'], $server_config[$v['server_id']]['dir']);
                 switch (intval($tmp['state'])) {
                     case 0:
                         //录制等待录制
                         $obj_curl->setSubmitType('get');
                         $obj_curl->initPostData();
                         $obj_curl->addRequestData('action', 'SELECT');
                         $obj_curl->addRequestData('id', $tmp['conid']);
                         $record_xml = $obj_curl->request('');
                         $record_array = xml2Array($record_xml);
                         if (!empty($record_array) && $record_array['result']) {
                             if ($record_array['record']['status'] == 'running') {
                                 $v['action'] = '录制中';
                             }
                             if ($record_array['record']['status'] == 'waiting') {
                                 if ($start_time + $v['toff'] <= ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW)) {
                                     $v['action'] = '录制超时';
                                 } else {
                                     $v['action'] = '等待录制';
                                 }
                             }
                         } else {
                             $v['action'] = '录制超时';
                         }
                         break;
                     case 1:
                         //录制成功
                         if ($tmp['week_day']) {
                             $v['action'] = '等待录制';
                         } else {
                             $v['action'] = $tmp['text'] ? $tmp['text'] : '录制超时';
                         }
                         break;
                     case 2:
                         //录制失败
                         if ($tmp['week_day']) {
                             $v['action'] = '等待录制';
                         } else {
                             $v['action'] = $tmp['text'] ? $tmp['text'] : '录制超时';
                         }
                         break;
                 }
             } else {
                 if ($start_time >= TIMENOW) {
                     $v['action'] = '等待录制';
                 } else {
                     if (TIMENOW > $start_time && TIMENOW < $v['toff'] + $start_time) {
                         $v['action'] = empty($week_day) ? '录制超时' : '等待录制';
                     } else {
                         if ($v['toff'] + $start_time <= TIMENOW) {
                             $v['action'] = empty($week_day) ? '录制超时' : '等待录制';
                             //假如is_record 存在video 在上传,否则就是录制成功
                         }
                     }
                 }
             }
         } else {
             $v['action'] = '服务停止';
         }
         if ($v['is_out']) {
             //$row['action'] = '录制超时';
         }
         if (!$v['status']) {
             $v['action'] = '频道关闭';
         }
         if (!$v['server_id']) {
             $v['action'] = '服务停止';
         }
         $info[] = $v;
     }
     return $info;
 }
Пример #12
0
 /**
  * 时移抓取
  * Enter description here ...
  * @param unknown_type $host
  * @param unknown_type $apidir
  * @param unknown_type $action TIMESHIFT
  * @param unknown_type $id
  * @param unknown_type $uploadFile 0
  * @param unknown_type $access_token
  * @param unknown_type $channel_id
  * @param unknown_type $url
  * @param unknown_type $callback
  */
 function recordOperate($host, $apidir, $data = array())
 {
     if (!$this->mRecordServer) {
         return array();
     }
     $this->mRecordServer->setUrlHost($host, $apidir);
     $this->mRecordServer->setSubmitType('get');
     $this->mRecordServer->initPostData();
     $this->mRecordServer->setReturnFormat('json');
     $action = array('TIMESHIFT');
     if (!in_array($data['action'], $action)) {
         return false;
     }
     foreach ($data as $k => $v) {
         $this->mRecordServer->addRequestData($k, $v);
     }
     $ret = $this->mRecordServer->request('');
     return xml2Array($ret);
 }
Пример #13
0
 public function delete_all()
 {
     if ($this->mNeedCheckIn && !$this->prms['manage']) {
         $this->errorOutput(NO_OPRATION_PRIVILEGE);
     }
     $id = urldecode($this->input['id']);
     if (!$id) {
         $this->errorOutput(OBJECT_NULL);
     } else {
         $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE id IN (" . $id . ")";
         $q = $this->db->query($sql);
         include_once ROOT_PATH . 'lib/class/curl.class.php';
         $this->curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
         $id_success = array();
         $ret = array();
         while ($row = $this->db->fetch_array($q)) {
             if ($row['conid'] && $row['start_time'] > TIMENOW + 5) {
                 $sql = "SELECT * FROM " . DB_PREFIX . "program_queue WHERE id=" . $row['conid'];
                 $tmp_first = $this->db->query_first($sql);
                 if (!empty($tmp_first)) {
                     $this->curl->mPostContentType('string');
                     $this->curl->setSubmitType('get');
                     $this->curl->setReturnFormat('json');
                     $this->curl->initPostData();
                     if (!defined('IS_WOZA') || !IS_WOZA) {
                         $this->curl->addRequestData('action', 'DELETE');
                     } else {
                         $this->curl->addRequestData('action', 'delete');
                     }
                     $this->curl->addRequestData('id', $tmp_first['conid']);
                     $record_xml = $this->curl->request('');
                     $record_array = xml2Array($record_xml);
                     if ($record_array['result']) {
                         $id_success[] = $row['id'];
                     }
                 }
             }
             $ret[] = $row;
         }
         $sql = "DELETE FROM " . DB_PREFIX . "program_record WHERE id IN (" . $id . ")";
         $this->db->query($sql);
         $sql = "DELETE FROM " . DB_PREFIX . "program_record_relation WHERE record_id IN (" . $id . ")";
         $this->db->query($sql);
         $sql = "DELETE FROM " . DB_PREFIX . "program_record_log WHERE record_id IN (" . $id . ")";
         $this->db->query($sql);
         $sql = "DELETE FROM " . DB_PREFIX . "program_queue WHERE record_id IN (" . $id . ")";
         $this->db->query($sql);
         $this->addLogs('delete', $ret, '');
     }
     $re = array();
     $re['id'] = $id;
     $this->setXmlNode('program_record', 'info');
     $this->addItem($re);
     $this->output();
 }
Пример #14
0
 /**
  * 显示录播节目单
  */
 function show()
 {
     if ($this->mNeedCheckIn && !$this->prms['show']) {
         $this->errorOutput(NO_OPRATION_PRIVILEGE);
     }
     $condition = $this->get_condition();
     $offset = $this->input['offset'] ? $this->input['offset'] : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 20;
     $data_limit = " LIMIT " . $offset . " , " . $count;
     $sql = "select p.*,c.name as channel,c.stream_state from " . DB_PREFIX . "program_record p left join " . DB_PREFIX . "channel c on c.id=p.channel_id ";
     $sql .= " where 1 " . $condition . " ORDER BY p.is_record ASC,p.start_time ASC " . $data_limit;
     $q = $this->db->query($sql);
     $week_day_arr = array('1' => '一', '2' => '二', '3' => '三', '4' => '四', '5' => '五', '6' => '六', '7' => '日');
     include_once ROOT_PATH . 'lib/class/livmedia.class.php';
     $livmedia = new livmedia();
     $sort_name = $livmedia->getAutoItem();
     $conid = $space = "";
     $data = array();
     while ($row = $this->db->fetch_array($q)) {
         $conid .= $space . $row['conid'];
         $space = ',';
         $data[] = $row;
     }
     $log = array();
     if ($conid) {
         $sql = "SELECT log_id FROM " . DB_PREFIX . "program_queue WHERE id IN(" . $conid . ")";
         $log_id = $space = '';
         $q = $this->db->query($sql);
         while ($row = $this->db->fetch_array($q)) {
             $log_id .= $space . $row['log_id'];
             $space = ',';
         }
         if ($log_id) {
             $sql = "SELECT a.*,q.conid FROM " . DB_PREFIX . "program_record_log a LEFT JOIN " . DB_PREFIX . "program_queue q ON a.id=q.log_id WHERE a.id IN (" . $log_id . ")";
             $q = $this->db->query($sql);
             $log = array();
             while ($row = $this->db->fetch_array($q)) {
                 $log[$row['record_id']] = $row;
             }
         }
     }
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     $obj_curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
     foreach ($data as $k => $v) {
         $dates = date('Y-m-d', $v['start_time']);
         $channel_id = $v['channel_id'];
         $start_time = $v['start_time'];
         $week_day = unserialize($v['week_day']);
         $v['start_time'] = date('H:i:s', $start_time);
         $v['end_time'] = date('H:i:s', $v['toff'] + $start_time);
         $mins = floor($v['toff'] / 60);
         $sen = $v['toff'] - $mins * 60;
         $v['toff_decode'] = ($mins ? $mins . "'" : '') . ($sen ? $sen . "''" : '');
         $v['dates'] = $dates;
         //$v['w'] = date('w',strtotime($start_time));
         $v['sort_name'] = $sort_name[$v['item']];
         $tmp = $log[$v['id']];
         if (!empty($week_day)) {
             if (count($week_day) == 7) {
                 $v['cycle'] = '每天';
             } else {
                 $spac = '';
                 foreach ($week_day as $kk => $vv) {
                     $v['cycle'] .= $spac . $week_day_arr[$vv];
                     $spac = '&nbsp;|&nbsp;';
                 }
             }
         } else {
             $v['cycle'] = date('Y-m-d', $start_time);
         }
         if ($tmp) {
             switch (intval($tmp['state'])) {
                 case 0:
                     //录制等待录制
                     $obj_curl->setSubmitType('get');
                     $obj_curl->initPostData();
                     $obj_curl->addRequestData('action', 'SELECT');
                     $obj_curl->addRequestData('id', $tmp['conid']);
                     $record_xml = $obj_curl->request('');
                     $record_array = xml2Array($record_xml);
                     if (!empty($record_array) && $record_array['result']) {
                         if ($record_array['record']['status'] == 'running') {
                             $v['action'] = '录制中';
                         }
                         if ($record_array['record']['status'] == 'waiting') {
                             if ($start_time + $v['toff'] <= ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW)) {
                                 $v['action'] = '录制超时';
                             } else {
                                 $v['action'] = '等待录制';
                             }
                         }
                     } else {
                         $v['action'] = '录制超时';
                     }
                     break;
                 case 1:
                     //录制成功
                     if ($tmp['week_day']) {
                         $v['action'] = '等待录制';
                     } else {
                         $v['action'] = $tmp['text'] ? $tmp['text'] : '录制超时';
                     }
                     break;
                 case 2:
                     //录制失败
                     if ($tmp['week_day']) {
                         $v['action'] = '等待录制';
                     } else {
                         $v['action'] = $tmp['text'] ? $tmp['text'] : '录制超时';
                     }
                     break;
             }
         } else {
             if ($start_time >= TIMENOW) {
                 $v['action'] = '等待录制';
             } else {
                 if (TIMENOW > $start_time && TIMENOW < $v['toff'] + $start_time) {
                     $v['action'] = empty($week_day) ? '录制超时' : '等待录制';
                 } else {
                     if ($v['toff'] + $start_time <= TIMENOW) {
                         $v['action'] = empty($week_day) ? '录制超时' : '等待录制';
                         //假如is_record 存在video 在上传,否则就是录制成功
                     }
                 }
             }
         }
         if ($v['is_out']) {
             //$row['action'] = '录制超时';
         }
         if (!$v['stream_state']) {
             $v['action'] = '频道关闭';
         }
         $info[] = $v;
     }
     foreach ($info as $key => $value) {
         $spa = '';
         $start_time = strtotime($value['dates'] . " " . $value['start_time']);
         $end_time = strtotime($value['dates'] . " " . $value['start_time']) + $value['toff'];
         $value['title'] = $value['title'] ? $value['title'] : $this->program_plan($value['channel_id'], $start_time, $end_time);
         $value['title'] = $value['title'] ? $value['title'] : '精彩节目';
         $value['source'] = $value['program_id'] ? '节目单' : ($value['plan_id'] ? '节目单计划' : '计划收录');
         //hg_pre($value);
         $this->addItem($value);
     }
     $this->output();
 }
Пример #15
0
 /**
  * 删除时移
  * $action	delete
  * 
  * Enter description here ...
  * @param unknown_type $id
  * @param unknown_type $time
  * @param unknown_type $callback
  * @param unknown_type $action
  */
 function dvrOperate($id, $time, $duration, $callback, $action = 'delete')
 {
     if (!$this->output) {
         return array();
     }
     $this->output->setSubmitType('post');
     $this->output->initPostData();
     $this->output->setReturnFormat('xml');
     $this->output->addRequestData('action', $action);
     $this->output->addRequestData('id', $id);
     $this->output->addRequestData('time', $time);
     $this->output->addRequestData('duration', $duration);
     $this->output->addRequestData('callback', $callback);
     $ret = $this->output->request('dvr');
     return xml2Array($ret);
 }
Пример #16
0
 /**
  * 删除录制后的时移
  * Enter description here ...
  * @param unknown_type $id
  */
 function recordDelete($host, $apidir, $id)
 {
     if (!$this->mRecordServer) {
         return array();
     }
     $this->mRecordServer->setUrlHost($host, $apidir);
     $this->mRecordServer->setSubmitType('get');
     $this->mRecordServer->initPostData();
     $this->mRecordServer->setReturnFormat('json');
     $this->mRecordServer->addRequestData('action', 'DELETE');
     $this->mRecordServer->addRequestData('id', $id);
     $ret = $this->mRecordServer->request('');
     return xml2Array($ret);
 }
Пример #17
0
 private function mediaServerOperate($host, $dir, $data = array())
 {
     $this->curl = new curl();
     if (!$this->curl) {
         return array();
     }
     $this->curl->setUrlHost($host, $dir);
     $this->curl->setSubmitType('get');
     $this->curl->initPostData();
     $this->curl->setReturnFormat('json');
     $action = array('MODIFY_CONFIG', 'GET_CONFIG');
     if (!in_array($data['action'], $action)) {
         return array();
     }
     foreach ($data as $k => $v) {
         $this->curl->addRequestData($k, $v);
     }
     $ret = $this->curl->request('');
     return xml2Array($ret);
 }
Пример #18
0
 public function delete()
 {
     $id = urldecode($this->input['id']);
     if (!$id) {
         $this->errorOutput(OBJECT_NULL);
     } else {
         $sql = "SELECT * FROM " . DB_PREFIX . "server_config WHERE 1 AND state=1";
         $q = $this->db->query($sql);
         $server_config = array();
         while ($row = $this->db->fetch_array($q)) {
             $server_config[$row['id']] = $row;
         }
         $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE id IN (" . $id . ")";
         $q = $this->db->query($sql);
         include_once ROOT_PATH . 'lib/class/live.class.php';
         $newLive = new live();
         $info = array();
         $channel_id = array();
         while ($row = $this->db->fetch_array($q)) {
             $info[] = $row;
             $channel_id[$row['channel_id']] = $row['channel_id'];
         }
         $channel_node = $channel_parent_node = array();
         if ($channel_id) {
             $channel = $newLive->getChannelById(implode(',', $channel_id), -1);
             if (!empty($channel)) {
                 foreach ($channel as $k => $v) {
                     $tmp_data = $newLive->getFatherNodeByid($v['node_id']);
                     $channel_node[$v['id']] = $tmp_data[0];
                     $channel_parent_node[$v['id']] = $v['node_id'];
                 }
             }
         }
         include_once ROOT_PATH . 'lib/class/curl.class.php';
         $id_success = array();
         $delete_id = $space = "";
         $ret = array();
         foreach ($info as $k => $row) {
             $this->curl = new curl($server_config[$row['server_id']]['host'] . ':' . $server_config[$row['server_id']]['port'], $server_config[$row['server_id']]['dir']);
             #####整合数据进行权限
             $nodes = array();
             $nodes['nodes'][$row['channel_id']] = $row['channel_id'];
             //hg_pre($nodes);exit;
             $this->verify_content_prms($nodes);
             if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
                 switch ($this->user['prms']['default_setting']['manage_other_data']) {
                     case 1:
                         //组织内,修改者和作者是否在同一组织
                         if ($this->user['org_id'] != $row['org_id']) {
                             $this->errorOutput(NO_PRIVILEGE);
                         }
                         break;
                     case 5:
                         //全部
                         break;
                     case 0:
                         //只能自己修改
                         if ($this->user['user_id'] != $row['user_id']) {
                             $this->errorOutput(NO_PRIVILEGE);
                         }
                         break;
                     default:
                         break;
                 }
             }
             #####整合数据进行权限结束
             if ($row['conid'] && $row['start_time'] > TIMENOW + 5) {
                 $sql = "SELECT * FROM " . DB_PREFIX . "program_queue WHERE id=" . $row['conid'];
                 $tmp_first = $this->db->query_first($sql);
                 if (!empty($tmp_first)) {
                     $this->curl->mPostContentType('string');
                     $this->curl->setSubmitType('get');
                     $this->curl->setReturnFormat('json');
                     $this->curl->initPostData();
                     if (!defined('IS_WOZA') || !IS_WOZA) {
                         $this->curl->addRequestData('action', 'DELETE');
                     } else {
                         $this->curl->addRequestData('action', 'delete');
                     }
                     $this->curl->addRequestData('id', $tmp_first['conid']);
                     $record_xml = $this->curl->request('');
                     $record_array = xml2Array($record_xml);
                     if ($record_array['result']) {
                         $id_success[] = $row['id'];
                     }
                 }
             }
             $delete_id .= $space . $row['id'];
             $space = ',';
             $ret[] = $row;
         }
         if ($delete_id) {
             $sql = "DELETE FROM " . DB_PREFIX . "program_record WHERE id IN (" . $delete_id . ")";
             $this->db->query($sql);
             $sql = "DELETE FROM " . DB_PREFIX . "program_record_relation WHERE record_id IN (" . $delete_id . ")";
             $this->db->query($sql);
             $sql = "DELETE FROM " . DB_PREFIX . "program_record_log WHERE record_id IN (" . $delete_id . ")";
             $this->db->query($sql);
             $sql = "DELETE FROM " . DB_PREFIX . "program_queue WHERE record_id IN (" . $delete_id . ")";
             $this->db->query($sql);
         }
         $this->addLogs('删除录制', $ret, '', '', '', '删除录制' . $delete_id);
     }
     $re = array();
     $id_array = explode(',', $id);
     $delid_array = explode(',', $delete_id);
     if (count($id_array) == count($delid_array)) {
         $re['info'] = '';
     } else {
         $re['info'] = '来自于节目单或者节目单计划的录制内容无法删除!';
     }
     $re['id'] = $delete_id;
     $this->setXmlNode('program_record', 'info');
     $this->addItem($re);
     $this->output();
 }
Пример #19
0
 function restart()
 {
     switch (intval($this->input['sort'])) {
         case 0:
             //重建当前时间之后所有的
             $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE start_time > " . TIMENOW . " AND conid <> 0";
             //. " AND (start_time+toff)<" . strtotime(date('Y-m-d',TIMENOW) . ' 23:59:59')
             //录制等待中的,并未开始录制,并且是当天,删除录制,重新提交
             $q = $this->db->query($sql);
             $queue_id = $record_id = $space = "";
             while ($row = $this->db->fetch_array($q)) {
                 $queue_id .= $space . $row['conid'];
                 //$record_id .= $space . $row['id'];
                 $space = ',';
             }
             if ($queue_id) {
                 $sql = "SELECT * FROM " . DB_PREFIX . "program_queue WHERE id IN(" . $queue_id . ")";
                 $q = $this->db->query($sql);
                 include_once ROOT_PATH . 'lib/class/curl.class.php';
                 $obj_curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
                 while ($row = $this->db->fetch_array($q)) {
                     $obj_curl->setSubmitType('get');
                     $obj_curl->initPostData();
                     $obj_curl->addRequestData('action', 'SELECT');
                     $obj_curl->addRequestData('id', $row['conid']);
                     $record_xml = $obj_curl->request('');
                     $record_array = xml2Array($record_xml);
                     if ($record_array) {
                         if ($record_array['result']) {
                             if ($record_array['record']['status'] == 'waiting') {
                                 $obj_curl->mPostContentType('string');
                                 $obj_curl->setSubmitType('get');
                                 $obj_curl->setReturnFormat('json');
                                 $obj_curl->initPostData();
                                 $obj_curl->addRequestData('action', 'DELETE');
                                 $obj_curl->addRequestData('id', $row['conid']);
                                 $record_xml = $obj_curl->request('');
                                 $record_array_delete = xml2Array($record_xml);
                                 /*
                                 if($record_array_delete['result'])
                                 {
                                 
                                 }
                                 */
                             }
                         }
                     }
                     //ing
                     $sql = "DELETE FROM " . DB_PREFIX . "program_record_log WHERE id=" . $row['log_id'];
                     $this->db->query($sql);
                     $sql = "DELETE FROM " . DB_PREFIX . "program_queue WHERE id=" . $row['id'];
                     $this->db->query($sql);
                     $update_sql = "UPDATE " . DB_PREFIX . "program_record SET is_record=0,conid=0 WHERE id=" . $row['record_id'];
                     //内容清空,录制清空
                     $this->db->query($update_sql);
                     echo $row['record_id'] . '-----------------ok<br/>';
                 }
             }
             break;
         case 1:
             $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE start_time > " . TIMENOW . " AND conid <> 0";
             //. " AND (start_time+toff)<" . strtotime(date('Y-m-d',TIMENOW) . ' 23:59:59')
             //录制等待中的,并未开始录制,并且是当天,删除录制,重新提交
             $q = $this->db->query($sql);
             $queue_id = $record_id = $space = "";
             while ($row = $this->db->fetch_array($q)) {
                 //$queue_id .= $space . $row['conid'];
                 $record_id .= $space . $row['id'];
                 $space = ',';
             }
             $update_sql = "UPDATE " . DB_PREFIX . "program_record SET is_record=0,conid=0 WHERE id IN(" . $record_id . ")";
             //内容清空,录制清空
             $this->db->query($update_sql);
             echo $record_id . '-----------------ok<br/>';
             break;
         case 2:
             //往后退一步
             $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE conid=0 and start_time > " . TIMENOW;
             //. " AND (start_time+toff)<" . strtotime(date('Y-m-d',TIMENOW) . ' 23:59:59')
             //录制等待中的,并未开始录制,并且是当天,删除录制,重新提交
             $q = $this->db->query($sql);
             $queue_id = $record_id = $space = "";
             $record = array();
             include_once ROOT_PATH . 'lib/class/curl.class.php';
             $obj_curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
             while ($row = $this->db->fetch_array($q)) {
                 $obj_curl->setSubmitType('get');
                 $obj_curl->initPostData();
                 $obj_curl->addRequestData('action', 'SELECT');
                 $obj_curl->addRequestData('id', $row['id']);
                 $record_xml = $obj_curl->request('');
                 $record_array = xml2Array($record_xml);
                 if ($record_array) {
                     if ($record_array['result']) {
                         if ($record_array['record']['status'] == 'waiting') {
                             print_r($row);
                             print_r($record_array);
                             $obj_curl->mPostContentType('string');
                             $obj_curl->setSubmitType('get');
                             $obj_curl->setReturnFormat('json');
                             $obj_curl->initPostData();
                             $obj_curl->addRequestData('action', 'DELETE');
                             $obj_curl->addRequestData('id', $row['id']);
                             $record_xml = $obj_curl->request('');
                             $record_array_delete = xml2Array($record_xml);
                             print_r($record_array_delete);
                             if ($record_array_delete['result']) {
                                 $row['conid'] ? $row['conid'] : $this->delete_queue($row['conid']);
                             }
                         }
                     }
                 } else {
                     //任务假如不存在,直接删除
                     $this->delete_queue($row['conid']);
                 }
                 $week_day = unserialize($row['week_day']);
                 if (is_array($week_day) && $week_day) {
                     $week_now = date('N', $row['start_time']);
                     $now = date('N');
                     if ($week_now >= $now) {
                         $ks = $week_now - $now;
                     } else {
                         $ks = $week_now - $now;
                     }
                     $start_time = $row['start_time'] - $ks * 86400 > TIMENOW ? $row['start_time'] - $ks * 86400 : $row['start_time'];
                     echo $row['id'] . '-----------------ok' . date('Y-m-d H:i:s', $start_time) . '<br/>';
                     $sql_update = "UPDATE " . DB_PREFIX . "program_record SET conid=0,is_record=0,start_time=" . $start_time . " WHERE id=" . $row['id'];
                     $this->db->query($sql_update);
                     echo $row['id'] . '-----------------ok<br/>';
                 } else {
                     $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_out=1,conid=0,is_record=1 WHERE id=" . $row['id'];
                     $this->db->query($sql_update);
                     echo $row['id'] . '-----------------ok<br/>';
                 }
             }
             break;
         default:
             break;
     }
     //录制
 }
Пример #20
0
 public function delete_log()
 {
     $id = $this->input['id'] ? $this->input['id'] : 0;
     $record_id = $this->input['record_id'] ? $this->input['record_id'] : 0;
     if (empty($id) || empty($record_id)) {
         $this->errorOutput('日志ID不存在');
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "program_record WHERE id=" . $record_id;
     $row = $this->db->query_first($sql);
     if ($row['start_time'] <= TIMENOW && TIMENOW <= $row['start_time'] + $row['toff']) {
         if (defined('IS_WOZA') && IS_WOZA) {
             $this->errorOutput('录制已经开始,无法删除');
             //woza录制无法删除正在录制中的。。。。
         }
     }
     //删除录制日志
     $sql = "DELETE FROM " . DB_PREFIX . "program_record_log WHERE id=" . $id;
     $this->db->query($sql);
     $week_day = unserialize($row['week_day']);
     if (is_array($week_day) && $week_day) {
         $week_now = date('N', $row['start_time']);
         $new_arr = array_flip($week_day);
         if (count($week_day) > $new_arr[$week_now] + 1) {
             $ks = $new_arr[$week_now] + 1;
         } else {
             $ks = 0;
         }
         $week_day = array_flip($new_arr);
         $next_week = $week_day[$ks] - $week_now > 0 ? $week_day[$ks] - $week_now : $week_day[$ks] - $week_now + 7;
         $start_time = $row['start_time'] + $next_week * 86400;
         $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_record=0,start_time=" . $start_time . " WHERE id=" . $row['id'];
         $this->db->query($sql_update);
     } else {
         $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_record=2 WHERE id=" . $row['id'];
         $this->db->query($sql_update);
     }
     if ($row['conid'] && $row['start_time'] > TIMENOW + 5) {
         $sql = "SELECT * FROM " . DB_PREFIX . "program_queue WHERE id=" . $row['conid'];
         $tmp_first = $this->db->query_first($sql);
         if (!empty($tmp_first)) {
             include_once ROOT_PATH . 'lib/class/curl.class.php';
             $this->curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
             $this->curl->mPostContentType('string');
             $this->curl->setSubmitType('get');
             $this->curl->setReturnFormat('json');
             $this->curl->initPostData();
             if (!defined('IS_WOZA') || !IS_WOZA) {
                 $this->curl->addRequestData('action', 'DELETE');
             } else {
                 $this->curl->addRequestData('action', 'delete');
             }
             $this->curl->addRequestData('id', $tmp_first['conid']);
             $record_xml = $this->curl->request('');
             $record_array = xml2Array($record_xml);
             $sql = "DELETE FROM " . DB_PREFIX . "program_queue WHERE record_id IN (" . $row['id'] . ")";
             $this->db->query($sql);
         }
     }
     $this->addItem(array('sucess' => 1));
     $this->output();
 }
 private function media_server_operate($time_shift_server, $data = array())
 {
     $curl = new curl();
     $curl->setUrlHost($time_shift_server['host'] . ($time_shift_server['port'] ? ':' . $time_shift_server['port'] : ''));
     $curl->setSubmitType('get');
     $curl->initPostData();
     $curl->setReturnFormat('json');
     foreach ($data as $k => $v) {
         $curl->addRequestData($k, $v);
     }
     $ret = $curl->request('');
     return xml2Array($ret);
 }
Пример #22
0
 /**
  * 用于已get方式提交到某一个地址
  * 返回json
  */
 public function curl_get($url, $type = 'json')
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     $response = curl_exec($ch);
     $head_info = curl_getinfo($ch);
     if ($head_info['http_code'] != 200) {
         $error = array('result' => 'fail');
         return json_encode($error);
     }
     curl_close($ch);
     //关闭
     if ($type == 'json') {
         return json_decode($response, true);
     } elseif ($type == 'px') {
         $response = explode(',', $response);
         if ($response[0] == 0) {
             $sucess = '01';
         } else {
             $sucess = $response[0];
         }
         $result = array('result' => $sucess, 'msgid' => $response[1]);
         return $result;
     } elseif ($type == 'xml') {
         $response = xml2Array($response);
         //
         $result = array('result' => $response['result'], 'msgid' => $response['taskid']);
         if (!intval($response['result'])) {
             $result['result'] = '01';
         } else {
             file_put_contents(CACHE_DIR . $response['taskid'] . '.txt', var_export($response, 1));
         }
         return $result;
     } elseif ($type == 'ps') {
         $result = array();
         parse_str($response, $result);
         $result['taskid'] && ($result['msgid'] = $result['taskid']);
         if (!intval($result['result'])) {
             $result['result'] = '01';
         } else {
             file_put_contents(CACHE_DIR . $result['taskid'] . '.txt', var_export($result, 1));
         }
         return $result;
     }
 }
Пример #23
0
 function show_program_record_status()
 {
     $id = intval($this->input['id']);
     $condition = ' AND a.id = ' . $id;
     $data_limit = '';
     $sql = "SELECT a.*,q.conid FROM  " . DB_PREFIX . "program_record_log a LEFT JOIN " . DB_PREFIX . "program_queue q ON a.id=q.log_id WHERE 1 " . $condition . " ORDER BY id DESC " . $data_limit;
     $info = $this->db->query_first($sql);
     //print_r($info);exit;
     if (!empty($info)) {
         $sql = "SELECT * FROM " . DB_PREFIX . "server_config WHERE 1 AND state=1";
         $q = $this->db->query($sql);
         $server_config = array();
         while ($row = $this->db->fetch_array($q)) {
             $server_config[$row['id']] = $row;
         }
         if ($info['record_id']) {
             $sql = "SELECT id,server_id FROM " . DB_PREFIX . "program_record WHERE id IN(" . $info['record_id'] . ")";
             $q = $this->db->query($sql);
             $record_server = array();
             while ($row = $this->db->fetch_array($q)) {
                 $record_server[$row['id']] = $row['server_id'];
             }
         }
         include_once ROOT_PATH . 'lib/class/curl.class.php';
         //			foreach($info as $k => $v)
         //			{
         if (empty($server_config[$record_server[$info['record_id']]])) {
             $obj_curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
         } else {
             $obj_curl = new curl($server_config[$record_server[$info['record_id']]]['host'] . ':' . $server_config[$record_server[$info['record_id']]]['port'], $server_config[$record_server[$info['record_id']]]['dir']);
         }
         $ret = array();
         $ret['id'] = $info['id'];
         $ret['channel_id'] = $info['channel_id'];
         $ret['record_id'] = $info['record_id'];
         $ret['dates'] = date('Y-m-d', $info['start_time']);
         //$pre_title = date('Y-m-d H:i:s',$info['start_time']) . '~~~' . date('Y-m-d H:i:s',($info['start_time']+$info['toff'])) . '--《' . $info['title'] . '》--------';
         switch (intval($info['state'])) {
             case 0:
                 //录制等待录制
                 $ret['state'] = 0;
                 $ret['operation'] = $info['text'];
                 $obj_curl->setSubmitType('get');
                 $obj_curl->initPostData();
                 $obj_curl->addRequestData('action', 'SELECT');
                 $obj_curl->addRequestData('id', $info['conid']);
                 $record_xml = $obj_curl->request('');
                 $record_array = xml2Array($record_xml);
                 if (!empty($record_array) && $record_array['result']) {
                     if ($record_array['record']['status'] == 'running') {
                         if ($info['start_time'] + $info['toff'] <= ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW)) {
                             $ret['operation'] = '录制超时';
                             $ret['state'] = 2;
                             $ret['has_completed'] = -1;
                         } else {
                             $ret['has_completed'] = ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW) - $info['start_time'];
                             $ret['operation'] = '录制中';
                             //.
                         }
                     }
                     if ($record_array['record']['status'] == 'waiting') {
                         if ($info['start_time'] + $info['toff'] <= ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW)) {
                             $ret['operation'] = '录制超时';
                             $ret['state'] = 2;
                             $ret['has_completed'] = -1;
                         } else {
                             $ret['operation'] = '等待录制';
                             //.$record_array['record']['startTime']
                             $ret['has_completed'] = -1;
                         }
                     }
                 } else {
                     $ret['operation'] = '录制超时';
                     $ret['state'] = 2;
                     $ret['has_completed'] = -1;
                 }
                 break;
             case 1:
                 //录制成功
                 $ret['state'] = 1;
                 $ret['operation'] = $info['text'] ? $info['text'] : '录制超时';
                 $ret['has_completed'] = ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW) - $info['start_time'];
                 break;
             case 2:
                 //录制失败
                 $ret['state'] = 2;
                 $ret['operation'] = $info['text'] ? $info['text'] : '录制超时';
                 $ret['has_completed'] = ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW) - $info['start_time'];
                 break;
         }
         $ret['auto'] = 1;
         $ret['toff'] = $info['toff'];
         $ret['isError'] = $ret['state'] == 2 ? 1 : 0;
         //$info['up_data'];
         $ret['operation'] = $ret['operation'];
         //			}
     }
     $this->addItem($ret);
     $this->output();
 }
Пример #24
0
 function copyDataFromRoomToRoom($old_id, $new_id, $user_id = '', $id_array = '')
 {
     $retour = parent::copyDataFromRoomtoRoom($old_id, $new_id, $user_id, $id_array);
     // group all
     $this->reset();
     $this->setContextLimit($old_id);
     $this->setExactNameLimit('ALL');
     $this->select();
     $old_list = $this->get();
     if ($old_list->isNotEmpty() and $old_list->getCount() == 1) {
         $old_group_all = $old_list->getFirst();
         $this->reset();
         $this->setContextLimit($new_id);
         $this->setExactNameLimit('ALL');
         $this->select();
         $new_list = $this->get();
         if ($new_list->isNotEmpty() and $new_list->getCount() == 1) {
             $new_group_all = $new_list->getFirst();
             $retour[$old_group_all->getItemID()] = $new_group_all->getItemID();
             unset($new_group_all);
         }
         unset($old_group_all);
     }
     unset($old_list);
     // images of labels
     $query = '';
     $query .= 'SELECT * FROM ' . $this->addDatabasePrefix($this->_db_table) . ' WHERE context_id="' . encode(AS_DB, $new_id) . '" AND deleter_id IS NULL AND deletion_date IS NULL';
     $result = $this->_db_connector->performQuery($query);
     if (!isset($result)) {
         include_once 'functions/error_functions.php';
         trigger_error('Problems getting data "' . $this->_db_table . '".', E_USER_WARNING);
     } else {
         foreach ($result as $query_result) {
             $extra_array = xml2Array($query_result['extras']);
             if (isset($extra_array['LABELPICTURE']) and !empty($extra_array['LABELPICTURE'])) {
                 $disc_manager = $this->_environment->getDiscManager();
                 $disc_manager->setPortalID($this->_environment->getCurrentPortalID());
                 if ($disc_manager->copyImageFromRoomToRoom($extra_array['LABELPICTURE'], $new_id)) {
                     $value_array = explode('_', $extra_array['LABELPICTURE']);
                     $value_array[0] = 'cid' . $new_id;
                     $extra_array['LABELPICTURE'] = implode('_', $value_array);
                     $update_query = 'UPDATE ' . $this->addDatabasePrefix($this->_db_table) . ' SET extras="' . encode(AS_DB, serialize($extra_array)) . '" WHERE item_id="' . $query_result['item_id'] . '"';
                     $update_result = $this->_db_connector->performQuery($update_query);
                     if (!isset($update_result) or !$update_result) {
                         include_once 'functions/error_functions.php';
                         trigger_error('Problems updating data "' . $this->_db_table . '".', E_USER_WARNING);
                     }
                 }
                 unset($disc_manager);
             }
         }
     }
     return $retour;
 }
Пример #25
0
   $row = mysql_fetch_row($result);
   $item_id = $row[0];
   $extra = $row[1];
   while ($item_id) {
      $room_id_array = array();
      $query2 = 'SELECT room.item_id FROM room WHERE context_id = "'.$item_id.'";';
      $result2 = select($query2);
      $row2 = mysql_fetch_row($result2);
      $room_id = $row2[0];
      while ($room_id) {
         $room_id_array[] = $room_id;
         $row2 = mysql_fetch_row($result2);
         $room_id = $row2[0];
      }

      $extra_array = xml2Array($extra);
      $default_auth_source_id = $extra_array['DEFAULT_AUTH'];
      $room_id_array[] = $item_id;

      $update_query = 'UPDATE user SET auth_source="'.$default_auth_source_id.'" WHERE context_id IN ('.implode(',',$room_id_array).')';
      $success2 = select($update_query);
      $success = $success and $success2;

      $row = mysql_fetch_row($result);
      $item_id = $row[0];
      $extra = $row[1];
      update_progress_bar($count);
   }
}

// end of execution time
Пример #26
0
 function show()
 {
     $ftp_server = "10.232.55.164";
     $ftp_port = 21;
     $ftp_user = "******";
     $ftp_pass = "******";
     $file_format = array("xml");
     //连接FTP服务器
     $conn_id = ftp_connect($ftp_server, $ftp_port);
     $f_dir = './XMLQIYI/';
     //
     $g_dir = CUR_CONF_PATH . 'data/ftp_tian/';
     $gf_dir = '/data/web/video.app.m2o/uploads/tianmai/';
     $count = 10;
     $cache_file = CACHE_DIR . 'queue_tian';
     if (file_exists($cache_file) && !$this->input['debug']) {
         $last_time = file_get_contents($cache_file);
         if ($this->input['queue']) {
             unlink($cache_file);
         } elseif (time() - $last_time > 600) {
             unlink($cache_file);
         } else {
             $this->errorOutput('当前有任务在执行。。。');
         }
     } else {
         if (hg_mkdir($g_dir)) {
             // 登陆FTP
             $file_name = array();
             if (ftp_login($conn_id, $ftp_user, $ftp_pass)) {
                 $tmp_dir = opendir($g_dir);
                 $i = 0;
                 while ($file = readdir($tmp_dir)) {
                     if ($file == '.' || $file == '..' || !in_array(substr(strrchr($file, '.'), 1), $file_format)) {
                         continue;
                     }
                     if ($i <= $count) {
                         $file_name[] = $file;
                     } else {
                         break;
                     }
                     $i++;
                 }
                 if (empty($file_name)) {
                     $filelist = ftp_rawlist($conn_id, $f_dir);
                     foreach ($filelist as $file) {
                         $tmp_filename = preg_replace("/.+[:]*\\d+\\s/", "", $file);
                         $tmp_name = mb_convert_encoding($tmp_filename, "GBK", "UTF-8");
                         if ($tmp_filename == '.' || $tmp_filename == '..' || !in_array(substr(strrchr($tmp_name, '.'), 1), $file_format)) {
                             continue;
                         }
                         ftp_get($conn_id, $g_dir . $tmp_filename, $f_dir . $tmp_filename, FTP_BINARY);
                         chmod($g_dir . $tmp_filename, 0777);
                     }
                     $tmp_dir = opendir($g_dir);
                     $i = 0;
                     while ($file = readdir($tmp_dir)) {
                         if ($file == '.' || $file == '..' || !in_array(substr(strrchr($file, '.'), 1), $file_format)) {
                             continue;
                         }
                         if ($i <= $count) {
                             $file_name[] = $file;
                         } else {
                             break;
                         }
                         $i++;
                     }
                 }
             }
             //	hg_pre($file_name);exit;
             if (!empty($file_name)) {
                 file_put_contents($cache_file, time());
                 chmod($cache_file, 0777);
                 $sql_ftp = "INSERT INTO " . DB_PREFIX . "ftp_source(vid,asset_id,parent_asset_id,name,tv_name,tv_id,index_num,create_time,update_time) VALUE ";
                 $insert_ftp = $space = '';
                 foreach ($file_name as $key => $value) {
                     echo $value . '<br/>';
                     $info = $data = array();
                     $filepath = $indexpic = '';
                     if (!file_exists($g_dir . $value)) {
                         continue;
                     }
                     $xml_data = file_get_contents($g_dir . $value);
                     if (!$this->xml_parser($xml_data)) {
                         unlink($g_dir . $value);
                         continue;
                     }
                     $array_data = xml2Array($xml_data);
                     $adi_data = $this->xml_content($array_data);
                     //处理xml内容
                     //hg_pre($adi_data);exit;
                     $asset_id = $adi_data['asset_id'];
                     $sql = "SELECT * FROM " . DB_PREFIX . "ftp_source WHERE asset_id='" . $asset_id . "'";
                     $f = $this->db->query_first($sql);
                     $column_id = $sort_id = 0;
                     $column_id = $adi_data['columnid'];
                     //	hg_pre($f);exit;
                     if (empty($f)) {
                         $info = array('title' => $adi_data['title'], 'subtitle' => '', 'keywords' => $adi_data['keywords'], 'comment' => $adi_data['newcontent'], 'author' => $adi_data['author'], 'vod_sort_id' => $adi_data['vod_sort_id'], 'column_id' => $adi_data['column_id'], 'start' => 0, 'duration' => '', 'audit_auto' => 2, 'create_time' => $adi_data['playTime'], 'appid' => APPID, 'appkey' => APPKEY, 'm2o_ckey' => M2OCKEY);
                         $info['a'] = 'create';
                         $tmp_array = explode('/', $adi_data['video_filename']);
                         $filename = $tmp_array[count($tmp_array) - 1];
                         $filepath = $adi_data['video_filename'];
                         //mb_convert_encoding(, "GBK", "UTF-8");
                         //	echo $g_dir . $filename;exit;
                         if (!file_exists($gf_dir . $filename)) {
                             @ftp_get($conn_id, $gf_dir . $filename, './' . $filepath, FTP_BINARY);
                             //	exit;
                             if (!file_exists($gf_dir . $filename) || filesize($gf_dir . $filename) <= 0) {
                                 //	unlink($gf_dir . $filename);//删除本地视频文件
                                 unlink($g_dir . $value);
                                 //删除本地adi
                                 ftp_delete($conn_id, './' . $filepath);
                                 //删除ftp视频文件
                                 ftp_delete($conn_id, $f_dir . $value);
                                 //删除ftp上adi
                                 continue;
                             } else {
                                 chmod($gf_dir . $filename, 0777);
                             }
                         }
                         //	$info['videofile'] = '@' . $g_dir . $filename;
                         $info['filepath'] = 'tianmai/' . $filename;
                         //	hg_pre($info);exit;
                         $url = 'http://' . $this->settings['App_mediaserver']['host'] . '/' . $this->settings['App_mediaserver']['dir'] . 'admin/create.php?format=json';
                         $ch = curl_init();
                         curl_setopt($ch, CURLOPT_URL, $url);
                         curl_setopt($ch, CURLOPT_HEADER, 0);
                         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                         curl_setopt($ch, CURLOPT_POST, 1);
                         curl_setopt($ch, CURLOPT_POSTFIELDS, $info);
                         $rt = curl_exec($ch);
                         curl_close($ch);
                         $rt = json_decode($rt, 1);
                         hg_pre($rt);
                         $rt = $rt[0];
                         if ($rt['id']) {
                             $insert_ftp = "(" . $rt['id'] . ",'" . $asset_id . "','','" . $title . "','',0,0," . TIMENOW . "," . TIMENOW . ")";
                             unlink($g_dir . $filename);
                             //删除本地视频文件
                             //	unlink($g_dir . $value);//删除本地adi
                             ftp_delete($conn_id, './' . $filepath);
                             //删除ftp视频文件
                             ftp_delete($conn_id, $f_dir . $value);
                             //删除ftp上adi
                             $this->db->query($sql_ftp . $insert_ftp);
                         }
                         hg_pre($rt);
                         exit;
                     } else {
                         $tmp_array = explode('/', $adi_data['video_filename']);
                         $filename = $tmp_array[count($tmp_array) - 1];
                         $filepath = $adi_data['video_filename'];
                         //mb_convert_encoding(, "GBK", "UTF-8");
                         //unlink($g_dir . $value);//删除本地adi
                         //@ftp_delete($conn_id, $f_dir . $value);//删除ftp上adi
                         //no update operate
                     }
                 }
                 //foreach
                 unlink($cache_file);
             }
             //echo $file_name;exit;
             ftp_close($conn_id);
             //断开ftp服务器连接
         }
     }
 }
Пример #27
0
 public function forward_common($data)
 {
     if (!$data) {
         return false;
     }
     $xml = $this->_common_xml($data);
     try {
         $cilentOptions = array('trace' => true, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE);
         $client = new SoapClient(WEB_URL, $cilentOptions);
         //echo $xml;exit();
         $ret_str = $client->InsertCaseInfo_GGFW(array('xmlCaseInfo' => $xml));
         $ret_str = $ret_str->InsertCaseInfo_GGFWResult;
         $ret_str = xml2Array($ret_str);
         if (!$ret_str['DATA']['ReturnInfo']['Status']) {
             $this->failed_data($data['id']);
             return false;
         }
     } catch (SoapFault $fault) {
         $this->failed_data($data['id']);
         return false;
         //echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring;exit();
     }
     return true;
 }
Пример #28
0
 /**
  * 显示录播节目单
  */
 function show()
 {
     $sql = "SELECT c.code, c.name,c.save_time,c.main_stream_name,c.stream_state,c.record_time,c.stream_id, pr.*,vs.sort_name\r\n\t\t\t\t\tFROM " . DB_PREFIX . "program_record pr \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "channel c \r\n\t\t\t\t\t\tON pr.channel_id=c.id \r\n\t\t\t\t\tLEFT JOIN " . DB_PREFIX . "vod_sort vs \r\n\t\t\t\t\t\tON pr.item=vs.id\r\n\t\t\t\tWHERE is_record=0 and (pr.start_time) > " . strtotime(date('Y-m-d', TIMENOW)) . " and pr.start_time < " . (strtotime(date('Y-m-d', TIMENOW)) + 86399);
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         $return = array();
         if (!$row['channel_id']) {
             continue;
         }
         $ret = array();
         $ret['record_id'] = $row['id'];
         $ret['channel_id'] = $row['channel_id'];
         $ret['name'] = $row['name'];
         $ret['program'] = $row['title'] ? $row['title'] : trim($this->program_plan($ret['channel_id'], $ret['starttime'], $ret['endtime']));
         $ret['title'] = trim($ret['program'] ? $ret['program'] : '精彩节目');
         $ret['starttime'] = $row['start_time'] + $row['record_time'];
         $ret['toff'] = $row['toff'];
         $ret['stream'] = hg_streamUrl($this->settings['mms']['output']['wowzaip'], $row['code'], $row['main_stream_name'] . $this->settings['mms']['output']['suffix'], '');
         $callback = $this->settings['App_mediaserver']['protocol'] . $this->settings['App_mediaserver']['host'] . '/' . $this->settings['App_mediaserver']['dir'] . 'admin/create.php?appid=' . $this->input['appid'] . '&appkey=' . $this->input['appkey'] . '&vod_leixing=3&auth=' . $this->settings['vodapi']['token'];
         $ret['save_time'] = $row['save_time'];
         $ret['delay_time'] = $row['live_delay'] * 60;
         $ret['source'] = $row['channel_id'];
         $ret['is_allow'] = $row['is_mark'];
         $ret['force_codec'] = $row['force_codec'];
         $ret['sort_name'] = $row['sort_name'];
         $ret['vod_sort_id'] = $row['item'];
         $ret['week_flag'] = $row['week_day'] ? 1 : 0;
         $ret['column_id'] = $row['columnid'] ? $row['columnid'] : 0;
         $ret['audit_auto'] = $row['audit_auto'] ? 2 : 0;
         foreach ($ret as $key => $value) {
             $callback .= '&' . $key . '=' . $value;
         }
         if ($row['columnid']) {
             $callback .= '&status=2';
         }
         $sql = "select id, ch_name,other_info,s_status from " . DB_PREFIX . "stream where id=" . $row['stream_id'];
         $stream = $this->db->query_first($sql);
         if (!$row['stream_state']) {
             $ret = array('errortext' => '视频流未开启!');
         } elseif (!$stream['s_status']) {
             $ret = array('errortext' => '视频上游流未开启!');
         } else {
             $this->curl->setSubmitType('post');
             $this->curl->setReturnFormat('json');
             $this->curl->initPostData();
             $this->curl->addRequestData('action', 'insert');
             $this->curl->addRequestData('url', $ret['stream']);
             $this->curl->addRequestData('callback', urlencode($callback));
             $this->curl->addRequestData('startTime', $ret['starttime'] - 1);
             $this->curl->addRequestData('duration', $row['toff'] + 1);
             $ret = array();
             $record_xml = $this->curl->request('');
             $record_array = xml2Array($record_xml);
             if (is_array($record_array)) {
                 $ret['id'] = $record_array['record']['id'] ? $record_array['record']['id'] : 0;
                 if (!$record_array['result']) {
                     $ret['errortext'] = $record_array['error']['message'];
                     //报错
                     $ret['isError'] = 1;
                 } else {
                     $ret['errortext'] = '';
                     $ret['isError'] = 0;
                 }
             } else {
                 $ret['id'] = 0;
                 $ret['errortext'] = '录制失败,无内容!';
                 $ret['isError'] = 1;
             }
             $is_record = $ret['id'] ? 1 : 0;
             //unset($pre_data['week_day']);
             $conid = $this->add_queue($row['id'], $ret['id']);
             if ($is_record) {
                 $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_out=0,conid=" . $conid . ",is_record=" . $is_record . " WHERE id=" . $row['id'];
                 $this->db->query($sql_update);
                 $sql = "select * from " . DB_PREFIX . "program_record where id=" . $row['id'];
                 $pre_data = $this->db->query_first($sql);
                 $pre_data['title'] = $pre_data['title'] ? $pre_data['title'] : '精彩节目';
                 $log_id = $this->logs->addLogs($ret['errortext'], $pre_data, $ret['isError'], $row['id'], $row['channel_id']);
                 $this->update_queue($conid, $log_id);
             } else {
                 if ($record_array['error']['message'] && !$row['is_out']) {
                     $week_day = unserialize($row['week_day']);
                     if (is_array($week_day) && $week_day) {
                         $week_now = date('N', $row['start_time']);
                         $new_arr = array_flip($week_day);
                         if (count($week_day) > $new_arr[$week_now] + 1) {
                             $ks = $new_arr[$week_now] + 1;
                         } else {
                             $ks = 0;
                         }
                         $week_day = array_flip($new_arr);
                         $next_week = $week_day[$ks] - $week_now > 0 ? $week_day[$ks] - $week_now : $week_day[$ks] - $week_now + 7;
                         $start_time = $row['start_time'] + $next_week * 86400;
                         $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_out=1,conid=0,is_record=" . $is_record . ",start_time=" . $start_time . " WHERE id=" . $row['id'];
                         $this->db->query($sql_update);
                     } else {
                         $sql_update = "UPDATE " . DB_PREFIX . "program_record SET is_out=1,conid=0,is_record=1 WHERE id=" . $row['id'];
                         $this->db->query($sql_update);
                     }
                     $sql = "select * from " . DB_PREFIX . "program_record where id=" . $row['id'];
                     $pre_data = $this->db->query_first($sql);
                     $pre_data['title'] = $pre_data['title'] ? $pre_data['title'] : '精彩节目';
                     $log_id = $this->logs->addLogs($ret['errortext'], $pre_data, $ret['isError'], $row['id'], $row['channel_id']);
                     $this->update_queue($conid, $log_id);
                 } else {
                     if (TIMENOW < $row['start_time']) {
                         //什么都不做还没开始录制
                     } else {
                         //woza断了,但照理的录制正在进行中,一旦woza开启就error,记录错误,更新记录
                         if (!$row['is_out']) {
                             $sql = "UPDATE " . DB_PREFIX . "program_record SET is_out=1 WHERE id=" . $row['id'];
                             //woza停止,改为超时,
                             $this->db->query($sql);
                             $sql = "select * from " . DB_PREFIX . "program_record where id=" . $row['id'];
                             $pre_data = $this->db->query_first($sql);
                             $pre_data['title'] = $pre_data['title'] ? $pre_data['title'] : '精彩节目';
                             $log_id = $this->logs->addLogs($ret['errortext'], $pre_data, $ret['isError'], $row['id'], $row['channel_id']);
                             $this->update_queue($conid, $log_id);
                         }
                     }
                 }
             }
         }
         $str = 'ID-' . $row['id'] . ($ret['errortext'] ? $ret['errortext'] : '录制成功');
         $this->tips($str, TIMENOW);
     }
 }
Пример #29
0
 public function sendSms($telephone = '', $type = 1)
 {
     if (!$telephone) {
         return false;
     }
     $config = $this->settings['sms_code'];
     $preg = array('{code}', '{time}');
     $replace = array($this->code, defined('AUTHCODE_EXPIRED') ? AUTHCODE_EXPIRED / 60 : 5);
     $content = str_replace($preg, $replace, $config['content'][$type]);
     $message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . "<message>" . "<account>" . $config['account'] . "</account>" . "<password>" . md5($config['password']) . "</password>" . "<msgid></msgid>" . "<phones>" . $telephone . "</phones>" . "<content>" . $content . "</content>" . "<sign>" . $config['sign'] . "</sign>" . "<subcode>" . $config['subcode'] . "</subcode>" . "<sendtime></sendtime>" . "</message>";
     $params = array('message' => $message);
     $data = http_build_query($params);
     $context = array('http' => array('method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => $data));
     $reponse = file_get_contents($config['request_send_url'], false, stream_context_create($context));
     if ($reponse) {
         $ret = xml2Array($reponse);
         if ($ret && is_array($ret) && !$ret['result']) {
             return true;
         }
         return false;
     } else {
         return false;
     }
 }
Пример #30
0
 function show()
 {
     if ($this->mNeedCheckIn && !$this->prms['manage_log']) {
         $this->errorOutput(NO_OPRATION_PRIVILEGE);
     }
     $state = array(0 => '等待录制', 1 => '录制成功', 2 => '录制失败');
     $content_id = 0;
     $condition = $this->get_condition();
     if ($this->input['record_id']) {
         $content_id = intval($this->input['record_id']);
         $condition .= " AND a.record_id=" . $content_id;
     }
     $sql = "SELECT id,stream_state FROM " . DB_PREFIX . "channel WHERE 1";
     $q = $this->db->query($sql);
     $channel = array();
     while ($row = $this->db->fetch_array($q)) {
         $channel[$row['id']] = $row['stream_state'];
     }
     $cond_data = array();
     $cond_data['offset'] = $this->input['offset'] ? $this->input['offset'] : 0;
     $cond_data['count'] = $this->input['count'] ? intval($this->input['count']) : 20;
     $data_limit = " LIMIT " . $cond_data['offset'] . "," . $cond_data['count'];
     $sql = "SELECT a.*,q.conid FROM  " . DB_PREFIX . "program_record_log a LEFT JOIN " . DB_PREFIX . "program_queue q ON a.id=q.log_id WHERE 1 " . $condition . " ORDER BY id DESC " . $data_limit;
     $q = $this->db->query($sql);
     $info = array();
     while ($row = $this->db->fetch_array($q)) {
         $info[] = $row;
     }
     if (!empty($info)) {
         include_once ROOT_PATH . 'lib/class/curl.class.php';
         $obj_curl = new curl($this->settings['mms']['record_server']['host'], $this->settings['mms']['record_server']['dir']);
         foreach ($info as $k => $v) {
             $ret = array();
             $ret[$k]['id'] = $v['id'];
             $ret[$k]['record_id'] = $v['record_id'];
             $ret[$k]['dates'] = date('Y-m-d', $v['start_time']);
             $pre_title = date('Y-m-d H:i:s', $v['start_time']) . '~~~' . date('Y-m-d H:i:s', $v['start_time'] + $v['toff']) . '--《' . $v['title'] . '》--------';
             switch (intval($v['state'])) {
                 case 0:
                     //录制等待录制
                     $ret[$k]['state'] = 0;
                     $ret[$k]['operation'] = $v['text'];
                     $obj_curl->setSubmitType('get');
                     $obj_curl->initPostData();
                     $obj_curl->addRequestData('action', 'SELECT');
                     $obj_curl->addRequestData('id', $v['conid']);
                     $record_xml = $obj_curl->request('');
                     $record_array = xml2Array($record_xml);
                     if (!empty($record_array) && $record_array['result']) {
                         if ($record_array['record']['status'] == 'running') {
                             $ret[$k]['has_completed'] = ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW) - $v['start_time'];
                             $ret[$k]['operation'] = '录制中';
                             //.
                         }
                         if ($record_array['record']['status'] == 'waiting') {
                             if ($v['start_time'] + $v['toff'] <= ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW)) {
                                 $ret[$k]['operation'] = '录制超时';
                                 $ret[$k]['state'] = 2;
                                 $ret[$k]['has_completed'] = -1;
                             } else {
                                 $ret[$k]['operation'] = '等待录制';
                                 //.$record_array['record']['startTime']
                                 $ret[$k]['has_completed'] = -1;
                             }
                         }
                     } else {
                         $ret[$k]['operation'] = '录制超时';
                         $ret[$k]['state'] = 2;
                         $ret[$k]['has_completed'] = -1;
                     }
                     break;
                 case 1:
                     //录制成功
                     $ret[$k]['state'] = 1;
                     $ret[$k]['operation'] = $v['text'] ? $v['text'] : '录制超时';
                     $ret[$k]['has_completed'] = ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW) - $v['start_time'];
                     break;
                 case 2:
                     //录制失败
                     $ret[$k]['state'] = 2;
                     $ret[$k]['operation'] = $v['text'] ? $v['text'] : '录制超时';
                     $ret[$k]['has_completed'] = ($record_array['record']['serverTime'] ? $record_array['record']['serverTime'] : TIMENOW) - $v['start_time'];
                     break;
             }
             if (!$channel[$v['channel_id']]) {
                 $ret[$k]['operation'] = '频道关闭';
                 $ret[$k]['state'] = 2;
             }
             //$ret[$k]['state'] = intval($v['state']);
             $ret[$k]['auto'] = 1;
             $ret[$k]['toff'] = $v['toff'];
             $ret[$k]['isError'] = $ret[$k]['state'] == 2 ? 1 : 0;
             //$v['up_data'];
             $ret[$k]['operation'] = $pre_title . $ret[$k]['operation'];
             //hg_pre($ret[$k]);
             $this->addItem($ret[$k]);
         }
     }
     $this->output();
 }