Ejemplo n.º 1
0
 public function handle($video_id, $uploadedfile, $title = "")
 {
     //源文件
     $image = getimagesize($uploadedfile);
     $width = $image[0];
     $height = $image[1];
     //文件名
     $file_name = md5($video_id) . ".jpg";
     $size = $this->settings['video_img_size'];
     //目录
     $file_dir = UPLOAD_DIR . VIDEO_DIR . ceil($video_id / NUM_IMG) . "/";
     //文件路径
     $file_path = $file_dir . $file_name;
     if (!hg_mkdir($file_dir)) {
         $this->errorOutput(UPLOAD_ERR_NO_FILE);
     }
     if (!copy($uploadedfile, $file_path)) {
         return "ID为" . $video_id . "视频《" . $title . "》缩略图<span style='color:red;'>生成失败!</span><br />";
     }
     $img = new GDImage($file_path, $file_path, '');
     $info = array();
     foreach ($size as $key => $value) {
         $new_name = $value['label'] . $file_name;
         $save_file_path = $file_dir . $new_name;
         $img->init_setting($file_path, $save_file_path, '');
         $img->maxWidth = $value['width'];
         $img->maxHeight = $value['height'];
         $img->makeThumb(3, false);
         $info[$key] = UPLOAD_URL . VIDEO_DIR . ceil($video_id / NUM_IMG) . "/" . $new_name;
     }
     $sql = "update " . DB_PREFIX . "video set images='" . $file_name . "' where id=" . $video_id;
     $this->db->query($sql);
     return "ID为" . $video_id . "视频《" . $title . "》缩略图生成成功!<br />";
 }
Ejemplo n.º 2
0
 public function startsnap()
 {
     $id = $this->input['channel_id'];
     $stream_uri = $this->input['stream_uri'];
     if (!$id || !$stream_uri) {
         $this->errorOutput('频道id或者流地址不能为空');
     }
     $time = $this->input['time'] ? $this->input['time'] : TIMENOW;
     $filename = TARGET_DIR . 'livesnap/' . $id . '/%d.png';
     hg_mkdir(TARGET_DIR . 'livesnap/' . $id);
     $cmd = 'ps -ef|grep ' . $stream_uri;
     exec($cmd, $out, $status);
     foreach ($out as $v) {
         if (strstr($v, FFMPEG_CMD)) {
             $v = preg_replace('/\\s+/is', ' ', $v);
             $pid = explode(' ', $v);
             $pid = intval($pid[1]);
             break;
         }
     }
     if ($pid) {
         $snap = array('channel_id' => $id, 'pid' => $pid);
         $this->addItem($snap);
         $this->output();
     }
     $snapinterval = intval($this->input['interval']);
     $snapinterval = $snapinterval ? $snapinterval : 1;
     $snapcmd = 'nohup ' . FFMPEG_CMD . ' -i ' . $stream_uri . ' -vcodec png -s 320x240 -r ' . $snapinterval . ' -y ' . $filename . ' > /dev/null &';
     exec($snapcmd, $out, $status);
     $snap = array('channel_id' => $id, 'snapcmd' => $snapcmd);
     $this->addItem($snap);
     $this->output();
 }
Ejemplo n.º 3
0
 private function auto_save_create($vcr)
 {
     //先插入fast_vcr_tmp表
     $data = array('user_id' => $this->user['user_id'], 'main_video_id' => $vcr['main_video_id'], 'vcr_type' => $vcr['vcr_type'], 'vodinfo_id' => $vcr['vodinfo_id'], 'input_point' => $vcr['input_point'], 'output_point' => $vcr['output_point'], 'hash_id' => $vcr['hash_id']);
     $sql = ' INSERT INTO ' . DB_PREFIX . 'fast_vcr_tmp SET ';
     foreach ($data as $k => $v) {
         $sql .= $k . ' = "' . $v . '",';
     }
     $sql = rtrim($sql, ',');
     $this->db->query($sql);
     //保存图片data数据
     $start_filename = $vcr['hash_id'] . '_start.img';
     $end_filename = $vcr['hash_id'] . '_end.img';
     if (!hg_mkdir(FAST_EDIT_IMGDATA_PATH) || !is_writeable(FAST_EDIT_IMGDATA_PATH)) {
         $this->errorOutput(NOWRITE);
     }
     if ($this->input['start_imgdata']) {
         @file_put_contents(FAST_EDIT_IMGDATA_PATH . $start_filename, $this->input['start_imgdata']);
     }
     if ($this->input['end_imgdata']) {
         @file_put_contents(FAST_EDIT_IMGDATA_PATH . $start_filename, $this->input['end_imgdata']);
     }
     $this->addItem('success');
     $this->output();
 }
Ejemplo n.º 4
0
 }
 public function __destruct()
 {
     parent::__destruct();
 }
 public function convert()
 {
     global $gGlobalConfig;
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     if ($gGlobalConfig['App_officeconvert']) {
         $curl = new curl($gGlobalConfig['App_officeconvert']['host'], $gGlobalConfig['App_officeconvert']['dir']);
     }
     $curl->setSubmitType('post');
     $curl->setReturnFormat('json');
     $curl->initPostData();
     $curl->addRequestData('custom_appid', CUSTOM_APPID);
     $curl->addRequestData('custom_appkey', CUSTOM_APPKEY);
     $curl->addFile($_FILES);
     $result = $curl->request('convert.php');
     //var_dump($result);exit;
     $path = 'cache/word/zip_' . uniqid() . '/';
     $zipDir = ROOT_PATH . $path;
     $return = array();
     if (hg_mkdir($zipDir) && is_writeable($zipDir)) {
         $zipFile = $zipDir . 'word.zip';
         file_put_contents($zipFile, $result);
         $unzipDir = $zipDir . 'unzip/';
         if (hg_mkdir($unzipDir) && is_writeable($unzipDir)) {
             $unzipCmd = ' unzip ' . $zipFile . ' -d ' . realpath($unzipDir);
             exec($unzipCmd);
             $rmZip = ' rm -f ' . $zipFile;
             exec($rmZip);
Ejemplo n.º 5
0
/**
 * 原目录,复制到的目录
 * */
function file_copy($from, $to, $filenamearr = array())
{
    $status = true;
    $dir = @opendir($from);
    if (!is_dir($to)) {
        @hg_mkdir($to);
    }
    while (false !== ($file = readdir($dir))) {
        if ($filenamearr) {
            if (!in_array($file, $filenamearr)) {
                continue;
            }
        }
        if ($file != '.' && $file != '..') {
            if (is_dir($from . '/' . $file)) {
                file_copy($from . '/' . $file, $to . '/' . $file, $filenamearr);
            } else {
                if (!@copy($from . '/' . $file, $to . '/' . $file)) {
                    $status = false;
                    break;
                }
            }
        }
    }
    closedir($dir);
    return $status;
}
Ejemplo n.º 6
0
 public function video()
 {
     $id = intval($this->input['id']);
     $f = $this->input['f'];
     $api = stripslashes(urldecode($_REQUEST['api']));
     $api = json_decode($api, true);
     if (!$id) {
         $this->ReportError('请指定要下载的视频!');
     }
     if (!$api || !$f) {
         $this->ReportError('未指定下载接口!');
     }
     $url = 'http://' . $api['host'] . '/' . $api['dir'] . $f . '?access_token=' . $this->user['token'] . '&id=' . $id;
     $filename = time() . mt_rand(1, 99999);
     hg_mkdir(ROOT_PATH . 'cache/tmp/');
     $tempfile = ROOT_PATH . 'cache/tmp/' . $filename . '.mp4';
     $count = 0;
     while (is_file($tempfile) && $count < 50) {
         $filename = time() . mt_rand(1, 99999);
         $tempfile = ROOT_PATH . 'cache/tmp/' . $filename . '.mp4';
     }
     $cmd = 'curl "' . $url . '" > ' . $tempfile;
     //$filesize = strlen($content);
     exec($cmd);
     $filesize = filesize($tempfile);
     if ($this->input['title']) {
         $filename = iconv('UTF-8', 'GBK', $this->input['title']);
     }
     header("Content-Type: application/force-download");
     header("Content-Transfer-Encoding: binary\n");
     header('Content-Length: ' . $filesize);
     header("Content-Disposition: attachment; filename=" . $filename . '.mp4');
     readfile($tempfile);
     @unlink($tempfile);
 }
Ejemplo n.º 7
0
 public function create()
 {
     if (!$_FILES['water_pic']) {
         $this->errorOutput('没有图片文件');
     }
     if (!hg_mkdir(TARGET_DIR . 'water/') || !is_writeable(TARGET_DIR . 'water/')) {
         $this->errorOutput(NOWRITE);
     }
     $original = $_FILES['water_pic']['name'];
     $filetype = strtolower(strrchr($original, '.'));
     //随机产生一个文件名
     $filename = TIMENOW . hg_rand_num(6) . $filetype;
     if (!@move_uploaded_file($_FILES['water_pic']['tmp_name'], TARGET_DIR . 'water/' . $filename)) {
         $this->errorOutput(FAILMOVE);
     }
     //图片文件传上去之后,记录数据库
     $data = array('name' => $this->input['name'], 'hostwork' => defined('TARGET_VIDEO_DOMAIN') && TARGET_VIDEO_DOMAIN ? ltrim(TARGET_VIDEO_DOMAIN, 'http://') : $this->settings['videouploads']['host'], 'base_path' => TARGET_DIR . 'water/', 'img_path' => $filename, 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'org_id' => $this->user['org_id']);
     $vid = $this->mode->create($data);
     if ($vid) {
         $data['id'] = $vid;
         $this->addLogs('创建水印', $data, '', '创建水印' . $vid);
         $this->addItem('success');
         $this->output();
     }
 }
Ejemplo n.º 8
0
 public function show()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE id = '" . intval($this->input['id']) . "'";
     $arr = $this->db->query_first($sql);
     if (!$arr) {
         $this->errorOutput('指定视频不存在');
     }
     $filename = iconv('UTF-8', 'GBK', $arr['title']);
     hg_mkdir(UPLOAD_DIR . 'tmp/download/');
     $tempfile = UPLOAD_DIR . 'tmp/download/' . time() . mt_rand(1, 99999) . '.mp4';
     $count = 0;
     while (is_file($tempfile) && $count < 50) {
         $tempfile = UPLOAD_DIR . 'tmp/download/' . time() . mt_rand(1, 99999) . '.mp4';
     }
     $cmd = 'curl "http://' . $this->settings['App_mediaserver']['host'] . '/' . $this->settings['App_mediaserver']['dir'] . 'admin/download.php?auth=' . $this->settings['App_mediaserver']['token'] . '&id=' . $arr['id'] . '" > ' . $tempfile;
     //$filesize = strlen($content);
     exec($cmd);
     $filesize = filesize($tempfile);
     header("Content-Type: application/force-download");
     header("Content-Transfer-Encoding: binary\n");
     header('Content-Length: ' . $filesize);
     header("Content-Disposition: attachment; filename=" . $filename . '.mp4');
     readfile($tempfile);
     $sql = 'UPDATE ' . DB_PREFIX . 'vodinfo SET downcount=downcount+1 WHERE id = ' . $arr['id'];
     $this->db->query($sql);
     @unlink($tempfile);
 }
Ejemplo n.º 9
0
 public function recommond_show()
 {
     if (!$this->input['column_id']) {
         $this->errorOutput('未传入栏目ID');
     }
     $columnd_id = $this->input['column_id'];
     $offset = $this->input['offset'] ? $this->input['offset'] : 0;
     $count = $this->input['count'] ? intval($this->input['count']) : 20;
     $file_name_prex = 'recommond-' . $columnd_id . '-';
     $dir = RECOMMOND_CACHE;
     $ret = array();
     if (hg_mkdir($dir)) {
         $file_name = $file_name_prex . $count . '-' . $offset . '.tmp';
         if (file_exists($dir . $file_name)) {
             $ret = json_decode(file_get_contents($dir . $file_name), true);
         } else {
             $condition = $this->get_condition();
             $data_limit = ' LIMIT ' . $offset . ' , ' . $count;
             $ret = $this->obj->show($condition . " ORDER BY orderid DESC " . $data_limit);
             file_put_contents($dir . $file_name, json_encode($ret));
         }
     }
     $this->addItem($ret);
     $this->output();
 }
Ejemplo n.º 10
0
 /**
  * 获取图片列表显示
  */
 function show()
 {
     $offset = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 0;
     $count = $this->input['count'] ? intval(urldecode($this->input['count'])) : 10;
     $limit = " limit {$offset}, {$count}";
     $condition = $this->get_condition();
     $sql = 'SELECT p.*,t.title as tuji_title,t.comment,t.path as tuji_path,s.sort_name FROM ' . DB_PREFIX . 'pics p LEFT JOIN ' . DB_PREFIX . 'tuji t ON p.tuji_id = t.id LEFT JOIN ' . DB_PREFIX . 'tuji_sort s ON s.id = t.tuji_sort_id WHERE 1 ' . $condition . ' ORDER BY create_time DESC ' . $limit;
     $this->setXmlNode('pics', 'pic');
     //print_r($this->db->fetch_all($sql));
     $q = $this->db->query($sql);
     while ($r = $this->db->fetch_array($q)) {
         $r['create_time'] = date('Y-m-d h:i:s', $r['create_time']);
         $r['update_time'] = date('Y-m-d h:i:s', $r['update_time']);
         $r['pic_url'] = UPLOAD_ABSOLUTE_URL . hg_num2dir($r['tuji_id']) . $r['new_name'];
         $r['description'] = $r['description'] ? $r['description'] : (!DESCRIPTION_TYPE ? $r['comment'] : '');
         unset($r['comment']);
         if ($this->input['width'] || $this->input['height']) {
             $subdir = hg_num2dir($r['tuji_id']) . intval($this->input['width']) . intval($this->input['height']) . '/';
             $thumb_dir = UPLOAD_THUMB_DIR . $subdir;
             if (!is_dir($thumb_dir)) {
                 @hg_mkdir($thumb_dir);
             }
             $thumb_file = $this->settings['thumb']['prefix'] . $r['new_name'];
             $this->gd->init_setting($r['pic_url'], $thumb_dir . $thumb_file);
             if ($location = $this->gd->makeThumb(1)) {
                 $r['thumb_url'] = UPLOAD_THUMB_URL . $subdir . $thumb_file;
             }
             //$r['thumb_url'] = $thumb_dir;
         }
         $this->addItem($r);
     }
     $this->output();
 }
Ejemplo n.º 11
0
function log2file($user, $level, $message, $input, $output = array())
{
    if (!LOG_LEVEL) {
        return;
    }
    if (LOG_FOR_USER != 'ALL' && $user['user_name'] != LOG_FOR_USER) {
        return;
    }
    $level = strtoupper($level);
    $log_level = array('ERROR' => 1, 'DEBUG' => 2, 'ALL' => 3);
    if ($log_level[$level] > LOG_LEVEL) {
        return;
    }
    $log_path = CUR_CONF_PATH . 'data/log/' . date('Y') . '/' . date('m') . '/';
    if (!is_dir($log_path)) {
        hg_mkdir($log_path);
    }
    $input = json_encode($input);
    $output = json_encode($output);
    $time = date('Y-m-d H:i');
    $user = @json_encode($user);
    $log_message_tpl = <<<LC
Level   : {$level}
Message : {$message}
Input   : {$input}
Ouput   : {$output}
Date\t: {$time}
User\t: {$user}


LC;
    hg_file_write($log_path . 'log-' . date('Y-m-d') . '.php', $log_message_tpl, 'a+');
}
Ejemplo n.º 12
0
function hg_debug_tofile($str = '', $is_arr = 0, $dir = '', $filename = 'log.txt', $op_type = 'a+', $tofile = true)
{
    if ($is_arr) {
        $str = var_export($str, true);
    }
    if ($op_type == "a" || $op_type == "a+") {
        if ($tofile) {
            $entersplit = "\r\n";
        } else {
            $entersplit = "<br />";
        }
    }
    $tmp_info = debug_backtrace();
    $str .= $entersplit;
    $debug_tree = "";
    $max = count($tmp_info);
    $i = 1;
    foreach ($tmp_info as $debug_info) {
        $space = str_repeat('&nbsp;&nbsp;', $max - $i);
        $debug_tree = $entersplit . $space . $debug_info['file'] . " on line " . $debug_info['line'] . ":" . $debug_tree;
        $i++;
    }
    $str = $entersplit . '[' . date('Y-m-d H:i:s') . ']' . $debug_tree . $str;
    if ($tofile) {
        $filename = $filename ? $filename : "log.txt";
        $filenamedir = explode('/', $filename);
        unset($filenamedir[count($filenamedir) - 1]);
        hg_mkdir(LOG_DIR . $dir . implode('/', $filenamedir));
        hg_file_write(LOG_DIR . $dir . $filename, $str, $op_type);
    } else {
        echo $str;
    }
}
Ejemplo n.º 13
0
 public function run()
 {
     //判断有没有登陆
     if (!$this->user['user_id']) {
         $this->errorOutput(NO_LOGIN);
     }
     //获取嘉宾信息
     $_memberInfo = $this->member_mode->detail('', " AND member_id = '" . $this->user['user_id'] . "' ");
     if (!$_memberInfo) {
         $this->errorOutput(YOU_HAVE_NOT_ACTIVATED);
     }
     //根据激活码id查询出激活码
     $code = $this->activate->detail($_memberInfo['activate_code_id']);
     if (!$code) {
         $code = array('guest_type_text' => $this->settings['guest_type'][1]);
     }
     //获取该嘉宾在用户中心的头像
     $avatar = array();
     if ($member_info = $this->getMemberInfoFromMemberCenter($this->user['user_id'])) {
         if ($member_info[0]) {
             $member_info = $member_info[0];
             if ($member_info['avatar'] && is_array($member_info['avatar'])) {
                 $avatar = $member_info['avatar'];
             }
         }
     }
     //更新库里面的头像
     $_avatar = $avatar && is_array($avatar) ? addslashes(serialize($avatar)) : '';
     if ($this->member_mode->update($_memberInfo['id'], array('avatar' => $_avatar))) {
         //构建名片数据
         $_vcard_data = array('id' => $_memberInfo['id'], 'name' => $_memberInfo['name'], 'company' => $_memberInfo['company'], 'job' => $_memberInfo['job'], 'telephone' => $_memberInfo['telephone'], 'email' => $_memberInfo['email'], 'avatar' => $avatar, 'guest_type_text' => $code['guest_type_text']);
         //引入二维码类
         if (!class_exists('QRcode')) {
             include_once CUR_CONF_PATH . 'lib/qrcode.class.php';
         }
         $_pic_name = $_memberInfo['vcard_pic_name'];
         $_isupdate = 0;
         //如果库里面二维码图片的名称都没有就产生图片名
         if (!$_pic_name) {
             $_pic_name = md5(TIMENOW . hg_rand_num(6)) . '.png';
             //随机产生图片文件名
             $_isupdate = 1;
         }
         if (!hg_mkdir(VCARD_DIR) || !is_writeable(VCARD_DIR)) {
             $this->errorOutput(NO_WRITE);
         }
         QRcode::png(json_encode($_vcard_data), VCARD_DIR . $_pic_name);
         //更新库里面的图片名称
         if ($_isupdate) {
             $this->member_mode->update($_memberInfo['id'], array('vcard_pic_name' => $_pic_name));
             $_memberInfo['vcard_pic_name'] = $_pic_name;
         }
     }
     $this->addItem(array('return' => 1));
     $this->output();
 }
Ejemplo n.º 14
0
 function recache($cache_name, $cache_dir = CACHE_DIR)
 {
     if (empty($cache_name)) {
         return false;
     }
     $material_type = $this->get_material_type();
     hg_mkdir($cache_dir);
     $cache_file = $cache_dir . $cache_name;
     hg_file_write($cache_file, serialize($material_type));
     return $material_type;
 }
Ejemplo n.º 15
0
function writeErrorLog($info = '')
{
    $path_dir = CACHE_DIR . 'error/';
    if (!hg_mkdir($path_dir) || !is_writeable($path_dir)) {
        return false;
    }
    $msg = "\n======================" . date('Y-m-d H:i:s', TIMENOW) . "============================\n";
    $msg .= $info;
    $msg .= "\n=====================================================================\n";
    file_put_contents($path_dir . 'error.log', $msg, FILE_APPEND);
}
Ejemplo n.º 16
0
 public function download_and_transcode()
 {
     //下载
     $data = $this->input;
     if (!$data) {
         return false;
     }
     $is_forcecode = intval($data['is_forcecode']);
     $url = $data['hostwork'] . '/' . $data['video_path'] . $data['video_filename'];
     //通过url下载视频
     $fileformat = substr($data['video_filename'], strrpos($data['video_filename'], '.'));
     $v_videodir = create_video_dir();
     $vod_dir_names = $v_videodir[0];
     $video_dir = $v_videodir[1];
     $filename = $vod_dir_names . $fileformat;
     $video_path = $video_dir;
     $video_base_path = TARGET_DIR;
     $video_filename = $filename;
     $source_hostwork = defined("SOURCE_VIDEO_DOMIAN") ? 'http://' . ltrim(SOURCE_VIDEO_DOMIAN, 'http://') : '';
     $source_base_path = UPLOAD_DIR;
     $source_path = 'yun/' . hg_build_dowload_dir();
     $source_filename = $data['video_filename'];
     $filepath = $source_base_path . $source_path;
     if (hg_mkdir($filepath)) {
         $file = file_get_contents($url);
         file_put_contents($filepath . $data['video_filename'], $file);
     }
     if (!hg_mkdir(TARGET_DIR . $video_dir) || !is_writeable(TARGET_DIR . $video_dir)) {
         $this->errorOutput(NOWRITE);
     }
     $sql = "UPDATE " . DB_PREFIX . "vodinfo SET source_hostwork='" . $source_hostwork . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  video_base_path = '" . $video_base_path . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  source_base_path = '" . $source_base_path . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  source_path = '" . $source_path . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  video_path = '" . $video_path . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  video_filename = '" . $video_filename . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  source_filename = '" . $source_filename . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  is_forcecode = '" . $is_forcecode . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  hostwork = 'http://" . TARGET_VIDEO_DOMAIN . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t  WHERE id = '" . $data['id'] . "'";
     $this->db->query($sql);
     if (defined('IS_TRANSCODE') && IS_TRANSCODE) {
         $sql = "UPDATE " . DB_PREFIX . "vodinfo SET status=0 WHERE id = '" . $data['id'] . "'";
         $this->db->query($sql);
         $ret = $this->submit_transcode($tr_data, $video_dir, $vod_dir_names, $data['id'], unserialize($data['img_info']));
         if (!$ret) {
             $ret['error'] = 'transcode';
         }
     } else {
         $target_file = TARGET_DIR . $video_path . $video_filename;
         $ret = copy($filepath . $data['video_filename'], $target_file);
         if (!$ret) {
             $ret['error'] = 'download';
         }
     }
     $this->publish_video($data['id'], 'insert');
     $this->addItem($ret);
     $this->output();
 }
Ejemplo n.º 17
0
 public function show()
 {
     if (!$this->user['user_id']) {
         $this->errorOutput(NO_LOGIN);
     }
     //获取嘉宾激活信息
     $_memberInfo = $this->member_mode->detail('', " AND member_id = '" . $this->user['user_id'] . "' ");
     if (!$_memberInfo) {
         $this->errorOutput(YOU_HAVE_NOT_ACTIVATED);
     }
     //根据激活码id查询出激活码
     $code = $this->activate->detail($_memberInfo['activate_code_id']);
     if (!$code) {
         $code = array('id' => 0, 'guest_type' => 1, 'guest_type_text' => $this->settings['guest_type'][1]);
     }
     //判断名片二维码存不存在,不存在就要生成一张
     if (!file_exists(VCARD_DIR . $_memberInfo['vcard_pic_name']) || !is_file(VCARD_DIR . $_memberInfo['vcard_pic_name'])) {
         //构建名片数据
         $_vcard_data = array('id' => $_memberInfo['id'], 'name' => $_memberInfo['name'], 'company' => $_memberInfo['company'], 'job' => $_memberInfo['job'], 'telephone' => $_memberInfo['telephone'], 'email' => $_memberInfo['email'], 'avatar' => $_memberInfo['avatar'] ? @unserialize($_memberInfo['avatar']) : array(), 'guest_type_text' => $code['guest_type_text']);
         //引入二维码类
         if (!class_exists('QRcode')) {
             include_once CUR_CONF_PATH . 'lib/qrcode.class.php';
         }
         $_pic_name = $_memberInfo['vcard_pic_name'];
         $_isupdate = 0;
         //如果库里面二维码图片的名称都没有就产生图片名
         if (!$_pic_name) {
             $_pic_name = md5(TIMENOW . hg_rand_num(6)) . '.png';
             //随机产生图片文件名
             $_isupdate = 1;
         }
         if (!hg_mkdir(VCARD_DIR) || !is_writeable(VCARD_DIR)) {
             $this->errorOutput(NO_WRITE);
         }
         QRcode::png(json_encode($_vcard_data), VCARD_DIR . $_pic_name);
         //更新库里面的图片名称
         if ($_isupdate) {
             $this->member_mode->update($_memberInfo['id'], array('vcard_pic_name' => $_pic_name));
             $_memberInfo['vcard_pic_name'] = $_pic_name;
         }
     }
     //获取自己已经交换名片的个数
     $_memberInfo['exchange_nums'] = $this->member_mode->get_exchanged_nums($_memberInfo['id']);
     $_memberInfo['vcard_url'] = $data['vcard_url'] = 'http://' . $this->settings['App_meeting']['host'] . '/' . $this->settings['App_meeting']['dir'] . 'data/vcard/' . $_memberInfo['vcard_pic_name'];
     $_memberInfo['avatar'] = $_memberInfo['avatar'] ? unserialize($_memberInfo['avatar']) : array();
     $_memberInfo['guest_type'] = $code['guest_type'];
     $_memberInfo['guest_type_text'] = $code['guest_type_text'];
     $this->addItem($_memberInfo);
     $this->output();
 }
Ejemplo n.º 18
0
/**
 * 创建图片
 * @param $uploadedfile 需生成的图片路径
 * @param $name 生成后的返回的图片名称
 * @param $path 需要存放的图片上级目录
 * @param $size 缩略图的尺寸(array)
 * @param $max_pixel 尺寸的最大值(M)
 * return 生成后的图片名
 */
function hg_mk_images($uploadedfile, $name, $path, $size, $max_pixel = 2)
{
    if (!$uploadedfile || !$name || !$path || !is_array($size)) {
        return OBJECT_NULL;
    }
    include_once ROOT_PATH . 'lib/class/gdimage.php';
    //源文件
    if (filesize($uploadedfile) / 1024 / 1024 >= $max_pixel) {
        return PIXEL_ERROR;
    }
    $image = getimagesize($uploadedfile);
    $width = $image[0];
    $height = $image[1];
    $file_name = $name;
    //目录
    $file_dir = $path;
    //文件路径
    $file_path = $file_dir . $file_name;
    if (!hg_mkdir($file_dir)) {
        return UPLOAD_ERR_NO_FILE;
    }
    if (!copy($uploadedfile, $file_path)) {
        return UPLOAD_ERR_NO_FILE;
    }
    $img = new GDImage($file_path, $file_path, '');
    foreach ($size as $key => $value) {
        $new_name = $value['label'] . $file_name;
        $save_file_path = $file_dir . $new_name;
        $img->init_setting($file_path, $save_file_path, '');
        $img->maxHeight = $value['height'];
        $img->maxWidth = $value['width'];
        /*
        	if($width > $height)
        	{
        		$img->maxWidth = $width > $value['width']?$value['width'] : $width;
        		$img->maxHeight = $height * ($img->maxWidth/$width);
        	}
        	else 
        	{
        		$img->maxHeight = $height > $value['height']?$value['height'] : $height;
        		$img->maxWidth = $width * ($img->maxHeight/$height);
        	}
        */
        $img->makeThumb(3);
    }
    return $file_name;
}
Ejemplo n.º 19
0
     }
 }
 public function vod2livets()
 {
     if (defined('FFMPED2TS_CMD') && FFMPED2TS_CMD) {
         $target = TARGET_DIR . $this->input['path'];
         $target_ts = TARGET_DIR . 'filestream/' . $this->input['targetpath'];
         $fromvideo = $this->input['filename'] . '.mp4';
         $ts_dur = intval(TS_DURATION) ? TS_DURATION : 10;
         hg_mkdir($target_ts);
         $cmd .= "\ncd {$target_ts}\n" . FFMPED2TS_CMD . ' -i ' . $target . $fromvideo . ' -f  segment -segment_time ' . $ts_dur . ' -segment_format mpegts -segment_list ' . $target_ts . 'playlist.m3u8  -codec copy -bsf:v h264_mp4toannexb -map 0 %d.ts';
         if ($this->input['debug']) {
             echo $cmd;
             exit;
         }
         exec($cmd);
         echo 'success';
Ejemplo n.º 20
0
 public function pick()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     //判断配置的提取的到哪个目录
     if (!file_exists(PICK_UP_DIR) || !is_writeable(PICK_UP_DIR)) {
         $this->errorOutput(DIR_NOT_EXISTS_OR_NOT_WRITEABLE);
     }
     //查询出需要提取的视频信息
     $sql = " SELECT * FROM " . DB_PREFIX . "vodinfo WHERE id IN (" . $this->input['id'] . ")";
     $q = $this->db->query($sql);
     $video = array();
     $videoInfo = array();
     while ($r = $this->db->fetch_array($q)) {
         $videoInfo[] = $r;
         $video_tmp = explode('.', $r['video_filename']);
         $video[] = array('id' => $r['id'], 'path' => rtrim($r['video_base_path'], '/') . '/' . $r['video_path'] . $r['video_filename'], 'title' => $r['starttime'] ? $r['title'] . '(' . date('Y-m-d', $r['starttime']) . ')' : $r['title'], 'type' => $video_tmp[1]);
     }
     //判断视频存不存在
     if (!$video) {
         $this->errorOutput(VIDEO_NOT_EXISTS);
     }
     //创建目录
     $targetDir = date('YmdHis', TIMENOW) . hg_rand_num(2) . '/';
     if (!hg_mkdir(PICK_UP_DIR . $targetDir) || !is_writeable(PICK_UP_DIR . $targetDir)) {
         $this->errorOutput(NOWRITE);
     }
     //copy视频到指定的目录
     foreach ($video as $k => $v) {
         $targetVideoPath = PICK_UP_DIR . $targetDir . $v['title'] . '.' . $v['type'];
         if (file_exists($targetVideoPath)) {
             $targetVideoPath = PICK_UP_DIR . $targetDir . $v['title'] . '(' . $v['id'] . ').' . $v['type'];
         }
         @copy($v['path'], $targetVideoPath);
     }
     //将视频的json信息放入该目录下
     file_put_contents(PICK_UP_DIR . $targetDir . 'videoinfo.json', json_encode($videoInfo));
     //将视频的xml信息放入该目录下
     //$xml = arrtoxml($videoInfo);
     //file_put_contents(PICK_UP_DIR . $targetDir . 'videoinfo.xml', $xml);
     //返回信息
     $ret = array('path' => PICK_UP_DIR . $targetDir);
     $this->addItem($ret);
     $this->output();
 }
Ejemplo n.º 21
0
 public function query($data = array())
 {
     if (!$data) {
         return false;
     }
     $ret = postCurl(TRAIN_API, $data);
     if (!$ret) {
         return false;
     }
     //如果需要缓存数据,就缓存数据
     if (IS_CACHE_TRAIN) {
         $filePath = TRAIN_DATA_CACHE;
         if (hg_mkdir(TRAIN_DATA_CACHE) && is_writeable(TRAIN_DATA_CACHE)) {
             file_put_contents(TRAIN_DATA_CACHE . $data['DepartCity'] . '#' . $data['ArriveCity'] . '#' . $data['DepartDate'] . '.txt', $ret);
         }
     }
     return $ret;
 }
Ejemplo n.º 22
0
 private function copyFilesToMedia($filenames, $dir = '')
 {
     if ($dir) {
         $dir = rtrim($dir, '/') . '/';
     }
     $path = FTP_UPLOAD_DIR . $dir;
     if (!$filenames) {
         return false;
     }
     $videoFileArr = explode(',', $filenames);
     //首先过滤提交的不合法的视频文件
     $videos = array();
     foreach ($videoFileArr as $k => $filename) {
         if (!file_exists($path . $filename) || !$this->check_type($filename)) {
             continue;
         }
         $videos[] = $filename;
     }
     //如果存在合法的视频文件,就先在meida里面创建创建目录用于摆放复制过来的视频
     if (!$videos) {
         return false;
     }
     $targetDir = TIMENOW . hg_rand_num(5) . '/';
     //随机产生一个目录
     if (!hg_mkdir(UPLOAD_DIR . $targetDir) || !is_writeable(UPLOAD_DIR . $targetDir)) {
         return false;
     }
     //复制视频到该目录
     $new_videos = array();
     foreach ($videos as $k => $v) {
         $filetype = strtolower(strrchr($v, '.'));
         $new_videos_name = TIMENOW . hg_rand_num(5) . $filetype;
         $status = @copy($path . $v, UPLOAD_DIR . $targetDir . $new_videos_name);
         //目录复制后删除原来目录
         if ($status && file_exists(UPLOAD_DIR . $targetDir . $new_videos_name)) {
             $new_videos[] = array('filename' => $new_videos_name, 'title' => substr($v, 0, strrpos($v, '.')));
             //删除原来的文件
             @unlink($path . $v);
             $this->saveFilePathToCache($path . $v);
         }
     }
     return array('file' => $new_videos, 'dir' => $targetDir);
 }
Ejemplo n.º 23
0
 public function create()
 {
     //权限
     $this->verify_content_prms(array('_action' => 'manage_verify_change'));
     $font = $_FILES['filedata'];
     $size = ini_get('upload_max_filesize');
     if (!$font) {
         $this->errorOutput('上传失败');
     }
     $tmp_size = substr($size, 0, -1);
     if ($font['size'] > $tmp_size * 1024 * 1024) {
         $this->errorOutput('字体包不得大于' . $size);
     }
     $uptypes = array('application/octet-stream');
     $ftype = $font["type"];
     if (!in_array($ftype, $uptypes)) {
         $this->errorOutput("文件格式不正确");
     }
     $data = array("name" => trim($font['name']), "create_time" => TIMENOW, "org_id" => $this->user['org_id'], "user_id" => $this->user['user_id'], "user_name" => $this->user['user_name'], "ip" => hg_getip());
     $this->data_check($data);
     //数据验证
     //上传文件
     $dir = FONT_DIR;
     if (!is_dir($dir)) {
         hg_mkdir($dir);
     }
     if (!move_uploaded_file($font['tmp_name'], $dir . $font['name'])) {
         $this->errorOutput('error');
     }
     //入库
     $vid = $this->mode->create($data, 'font');
     if ($vid) {
         $data['id'] = $vid;
         $tmp = explode('.', $data['name']);
         $data['name'] = $tmp[0];
         $data['type'] = $tmp[1];
         $data['status'] = 0;
         $data['create_time'] = date('Y-m-d H:i', $data['create_time']);
         //$this->addLogs('创建',$data,'','创建' . $vid);此处是日志,自己根据情况加一下
         $this->addItem($data);
         $this->output();
     }
 }
Ejemplo n.º 24
0
 public function run()
 {
     $condition = '';
     if ($this->input['start']) {
         $condition .= " AND id >= '" . $this->input['start'] . "' ";
     }
     if ($this->input['end']) {
         $condition .= " AND id <= '" . $this->input['end'] . "' ";
     }
     if ($this->input['ids']) {
         $condition .= " AND id IN (" . $this->input['ids'] . ") ";
     }
     if ($this->input['vod_sort_id']) {
         $condition .= " AND vod_sort_id = '" . $this->input['vod_sort_id'] . "' ";
     }
     if (!$condition) {
         $this->errorOutput('条件不能为空');
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE 1 " . $condition;
     $q = $this->db->query($sql);
     while ($r = $this->db->fetch_array($q)) {
         if (!file_exists($r['video_base_path'] . $r['video_path'] . $r['video_filename'])) {
             echo "id:" . $r['id'] . " 文件找不到 <br/>";
             continue;
         }
         if (!hg_mkdir($r['video_base_path'] . $r['video_path'] . 'new_preview/') || !is_writeable($r['video_base_path'] . $r['video_path'] . 'new_preview/')) {
             $this->errorOutput(NOWRITE);
         }
         $path = $this->snap->snapPicture($r['video_base_path'] . $r['video_path'] . $r['video_filename'], $r['video_base_path'] . $r['video_path'] . 'new_preview/');
         if ($path) {
             $img_info = $this->material->localMaterial($path, $r['id']);
             if ($img_info && $img_info[0]) {
                 $img_info = $img_info[0];
                 $image_info = array('host' => $img_info['host'], 'dir' => $img_info['dir'], 'filepath' => $img_info['filepath'], 'filename' => $img_info['filename'], 'imgwidth' => $img_info['imgwidth'], 'imgheight' => $img_info['imgheight']);
                 $sql = " UPDATE " . DB_PREFIX . "vodinfo SET img_info = '" . serialize($image_info) . "'  WHERE id = '" . $r['id'] . "'";
                 $this->db->query($sql);
             }
         }
         echo "id:" . $r['id'] . " 完成 <br/>";
     }
     echo "完成 <br/>";
 }
Ejemplo n.º 25
0
 public function uploadImg()
 {
     $files = $_FILES;
     if (!$files) {
         $this->ReportError(UPLOAD_ERR_NO_FILE);
     }
     $type = substr($files['pic1']['name'], strrpos($files['pic1']['name'], '.') + 1);
     $admit_type = array('jpg', 'gif', 'png', 'jpeg');
     if (!in_array($type, $admit_type)) {
         $this->ReportError($this->lang['error_type']);
     }
     if ($files['pic1']['size'] > BGIMG_MAX_SIZE) {
         $this->ReportError($this->lang['over_size']);
     }
     $uploadedfile = $files['pic1']['tmp_name'];
     //源文件
     $file_name = $this->user['id'] . ".jpg";
     //文件名
     $file_dir = USER_BGIMG_DIR . ceil($userinfo['id'] / NUM_IMG) . '/' . $this->user['id'] . "/";
     //目录
     //文件路径
     $file_path = $file_dir . $file_name;
     if (!hg_mkdir($file_dir)) {
         $this->ReportError($this->lang['mkdir_fail']);
     }
     if (!copy($uploadedfile, $file_path)) {
         $this->ReportError(UPLOAD_ERR_NO_FILE);
     } else {
         $result = 1;
     }
     $filedir = USER_BGIMG_URL . $this->user['id'] . '/' . $file_name;
     if (!$result) {
         echo $this->lang['upload_fail'];
     } else {
         $flie = array('imgsrc' => $filedir, 'success' => $this->lang['success']);
         $flie = json_encode($flie);
         echo '<script>parent.endUpload("' . addslashes($flie) . '")</script>';
     }
 }
Ejemplo n.º 26
0
* 返回: 视频转码状态及信息
* 错误返回: 001 - 未指定视频ID, 002 - 未找到视频信息
*/
if (!in_array($_INPUT['auth'], $gToken)) {
    error_output('009', '通信令牌错误');
}
$id = $_INPUT['id'];
if (!$id) {
    error_output('001', '未指定视频ID');
}
$video_dir = hg_num2dir($id) . $id . '.ssm/';
$mp4 = TARGET_DIR . $video_dir . $id . '.mp4';
$ismv = TARGET_DIR . $video_dir . $id . '.ismv';
if (!is_file($mp4) && is_file($ismv)) {
    $cmd = '/usr/local/bin/mp4split -o ' . $mp4 . ' ' . $ismv;
    hg_mkdir(TARGET_DIR . $video_dir);
    exec($cmd);
}
if (!is_file($mp4)) {
    error_output('002', '视频文件不存在');
} else {
    if ($_INPUT['a'] == 'geturl') {
        $arr = array('url' => THUMB_URL . $video_dir . $id . '.mp4');
        echo json_encode($arr);
        exit;
    }
    $filesize = filesize($mp4);
    header("Content-Type: application/force-download");
    header("Content-Transfer-Encoding: binary\n");
    header('Content-Length: ' . $filesize);
    readfile($mp4);
Ejemplo n.º 27
0
 public function get_component($id)
 {
     $data = $this->get_style($id);
     $cache_theme_dir = DATA_DIR . 'component/';
     $cache_tem_dir = $cache_theme_dir . $data['sign'] . '_' . $data['theme'] . '/';
     $theme_dir = CORE_DIR . 'global/';
     $tem_dir = CORE_DIR . $data['sign'] . '_' . $data['theme'] . '/component/';
     $com = array_merge($this->settings['standard'], $this->settings['fixed']);
     $com[] = 'header_info';
     $com[] = 'footer_info';
     $com[] = 'captcha';
     if (file_exists($cache_tem_dir . '/component.php') && !$this->updateCache) {
         $tcomponent = file_get_contents($cache_tem_dir . 'component.php');
         $t_com = json_decode($tcomponent, 1);
     } elseif ($com && is_array($com)) {
         if (file_exists($cache_theme_dir . 'component.php') && !$this->updateCache) {
             $gcomponent = file_get_contents($cache_theme_dir . 'component.php');
             $g_com = json_decode($gcomponent, 1);
         } else {
             foreach ($com as $k => $v) {
                 if ($v) {
                     $g_com[$v] = file_get_contents($theme_dir . $v . '.html');
                 }
             }
             if (!is_dir($cache_theme_dir)) {
                 hg_mkdir($cache_theme_dir);
             }
             file_put_contents($cache_theme_dir . 'component.php', json_encode($g_com));
         }
         foreach ($com as $k => $v) {
             if ($v && file_exists($tem_dir . $v . '.html')) {
                 $t_com[$v] = file_get_contents($tem_dir . $v . '.html');
             } else {
                 $t_com[$v] = $g_com[$v];
             }
         }
         if (!is_dir($cache_tem_dir)) {
             hg_mkdir($cache_tem_dir);
         }
         file_put_contents($cache_tem_dir . 'component.php', json_encode($t_com));
     }
     return $t_com;
 }
Ejemplo n.º 28
0
 /**
  *  输出调试结果,debug用
  *
  */
 protected function debug($data = '')
 {
     if (DEBUG_MODE) {
         if (1 == DEBUG_MODE) {
             if (!is_string($data)) {
                 print_r($data);
             } else {
                 echo $data;
             }
             echo '<br />#----------------------------------------------------------------------------------------------------------------------------#<br />';
             echo hg_page_debug();
         } else {
             hg_mkdir(LOG_DIR);
             hg_debug_tofile($data, 1, LOG_DIR . 'debug.txt');
         }
     }
 }
Ejemplo n.º 29
0
 private function get_data()
 {
     //请求多接口,不需要对返回值做处理,只需要缓存
     if ($this->hg_extend_api && $this->hg_settings['extend_api_switch']) {
         //判断移动app,host,dir是否存在
         if (!$this->settings['App_mobile']['host'] || !$this->settings['App_mobile']['dir']) {
             $this->errorOutput(UNKNOW_HOST);
         }
         $this->curl = new curl();
         //hg_pre($this->hg_extend_api,0);
         $path = '';
         $path = $this->settings['App_mobile']['host'] . '/' . $this->settings['App_mobile']['dir'] . 'data/' . $this->hg_settings['sort_dir'];
         $this->curl->mRequestData = $this->input;
         foreach ($this->hg_extend_api as $k => $filename) {
             $res = '';
             $url = '';
             $url = $path . $filename;
             $res = $this->curl->post_files($url);
             if (!$res) {
                 $data[$k] = array();
             } else {
                 if (!is_array($res)) {
                     $res = json_decode($res, 1);
                 }
                 $data[$k] = $res;
             }
         }
         //hg_pre($data,0);
     } else {
         //初始化curl
         if ($this->hg_settings['bundle']) {
             $this->hg_settings['host'] = $this->settings['App_' . $this->hg_settings['bundle']]['host'];
             $this->hg_settings['dir'] = $this->settings['App_' . $this->hg_settings['bundle']]['dir'];
         }
         //判断host,dir是否存在
         if (!$this->hg_settings['host'] || !$this->hg_settings['dir']) {
             $this->errorOutput(UNKNOW_HOST);
         }
         //参数处理代码
         $this->curl = new curl($this->hg_settings['host'], $this->hg_settings['dir']);
         $this->curl->initPostData();
         $this->curl->setCharset($this->hg_settings['codefmt']);
         if ($this->hg_agruments) {
             foreach ($this->hg_agruments['ident'] as $k => $v) {
                 if ($v == 'formdata') {
                     continue;
                 }
                 if ($v == 'callback') {
                     $this->input['callback'] = $this->hg_agruments['value'][$k];
                     continue;
                 }
                 $file_tag = 0;
                 $ident_input = '';
                 //1=>user 0=>sys
                 if (!$this->hg_agruments['add_status'][$k]) {
                     $va = $this->hg_agruments['value'][$k];
                 } else {
                     if ($this->hg_agruments['add_status'][$k] == 1) {
                         $ident_input = $this->hg_agruments['ident_input'][$k];
                         if ($ident_input && isset($this->input[$ident_input])) {
                             $va = $this->input[$ident_input];
                         } elseif (isset($this->input[$v])) {
                             $va = $this->input[$v];
                         } elseif ($this->hg_agruments['value'][$k]) {
                             $va = $this->hg_agruments['value'][$k];
                         } else {
                             continue;
                         }
                     } else {
                         if ($this->hg_agruments['add_status'][$k] == 2) {
                             $file_tag = 1;
                         }
                     }
                 }
                 if (!$file_tag) {
                     //$con[$v] = $va; //请求接口条件
                     if ($this->hg_settings['codefmt'] && $this->hg_settings['codefmt'] != 'UTF-8') {
                         $va = iconv($this->hg_settings['codefmt'], 'UTF-8//IGNORE', $va);
                     }
                     //防止用户提交的内容里面@符开头,curl在请求的时候报错
                     if ($va && $va[0] == '@') {
                         $va = ' ' . $va;
                     }
                     if (is_array($va)) {
                         $this->array_to_add($v, $va);
                     } else {
                         $this->curl->addRequestData($v, $va);
                     }
                 } else {
                     if ($_FILES) {
                         $this->curl->addFile($_FILES);
                     }
                 }
             }
         }
         if ($this->hg_settings['request_type'] == '1') {
             $SubmitType = 'get';
         } else {
             if ($this->hg_settings['request_type'] == '2') {
                 $SubmitType = 'post';
             }
         }
         $this->curl->setSubmitType($SubmitType);
         if ($this->hg_settings['protocol'] == 1) {
             $protocol = 'http';
         } else {
             $protocol = 'https';
         }
         $this->curl->setRequestType($protocol);
         //curl数据返回格式
         if ($this->hg_settings['direct_return']) {
             $this->curl->setReturnFormat('str');
         } else {
             if ($this->hg_settings['data_format']) {
                 $data_type = strtolower($this->settings[$this->hg_settings['data_format']]);
                 if (in_array($data_type, array('json', 'xml', 'str'))) {
                     $this->curl->setReturnFormat($data_type);
                 }
             }
         }
         //请求结果
         $data = $this->curl->request("news.php");
         if (!is_array($data)) {
             $data = json_decode($data, 1);
         }
         //返回值处理代码
         //curl返回数据有错误时直接输出错误
         if (!$data || is_array($data) && $data['ErrorCode']) {
             $data = json_encode($data);
             if ($this->input['callback']) {
                 header('Content-Type: text/javascript');
                 $data = $this->input['callback'] . '(' . $data . ')';
             }
             //返回值替换
             if ($this->hg_map_val) {
                 foreach ($this->hg_map_val as $k => $v) {
                     $k = trim(json_encode($k), '"');
                     $v = trim(json_encode($v), '"');
                     $data = str_replace($k, $v, $data);
                 }
             }
             echo $data;
             exit;
         }
         //有数据返回节点设置,返回节点里的数据
         if ($this->hg_settings['data_node'] || $this->hg_settings['data_node'] == '0') {
             if (!is_array($data)) {
                 $data = json_decode($data, 1);
             }
             $data_node = $this->hg_settings['data_node'];
             //$data_node = '1';
             $data_node_arr = array();
             $data_node_arr = explode(',', $data_node);
             $data1 = array();
             if (!empty($data_node_arr) && count($data_node_arr) > 1) {
                 foreach ($data_node_arr as $val) {
                     $arr = array();
                     $arr = explode('=', $val);
                     if ($arr[1]) {
                         $fileds = array();
                         $fileds = explode('/', $arr[1]);
                         $temp = '';
                         foreach ($fileds as $k) {
                             if ($data[$k]) {
                                 $temp = $data[$k];
                             } else {
                                 if ($temp[$k]) {
                                     $temp = $temp[$k];
                                 }
                             }
                             if ($temp) {
                                 $data1[$arr[0]] = $temp;
                             } else {
                                 $data1[$arr[0]] = '';
                             }
                         }
                     } else {
                         if ($data[$arr[0]]) {
                             $data1[$arr[0]] = $data[$arr[0]];
                         }
                     }
                 }
             } else {
                 $data1 = $data[$data_node_arr[0]];
             }
             if ($data1) {
                 $data = $data1;
             }
             if ($data[$this->hg_settings['data_node']]) {
                 //$data = $data[$this->hg_settings['data_node']];
             }
         }
         //替换返回值
         if ($data && $this->hg_map_val) {
             if (is_array($data)) {
                 $data = json_encode($data);
             }
             foreach ($this->hg_map_val as $k => $v) {
                 $k = trim(json_encode($k), '"');
                 $v = trim(json_encode($v), '"');
                 $data = str_replace($k, $v, $data);
             }
             //$data = json_decode($data,1);
             //hg_pre($data,0);
         }
         //直接返回
         if ($this->hg_settings['direct_return']) {
             if (is_array($data)) {
                 $data = json_encode($data);
             }
             if ($this->input['callback']) {
                 header('Content-Type: text/javascript');
                 $data = $this->input['callback'] . '(' . $data . ')';
             }
             //返回值替换
             /*if($this->hg_map_val)
             		{
             			foreach ($this->hg_map_val as $k => $v)
             		{
             			$k = trim(json_encode($k),'"');
             			$v = trim(json_encode($v),'"');
             			$data = str_replace($k, $v, $data);
             		}
             		}*/
             echo $data;
             exit;
         }
         //替换映射字段
         if ($data && $this->hg_maps) {
             $info = array();
             if (!is_array($data)) {
                 $info = json_decode($data, 1);
             } else {
                 $info = $data;
             }
             foreach ($this->hg_maps as $k => $v) {
                 $k = ltrim(html_entity_decode($k, ENT_QUOTES), '{');
                 $map_info[$v] = explode('}{', rtrim($k, '}'));
             }
             if ($map_info && !empty($info)) {
                 $data = array();
                 foreach ($info as $key => $value) {
                     foreach ($map_info as $k => $val) {
                         if (!$val || !is_array($val)) {
                             continue;
                         }
                         foreach ($val as $kk => $v) {
                             if (substr($v, 0, 1) == '$') {
                                 $value[$k] .= $value[ltrim($v, '$')];
                             } else {
                                 $value[$k] .= $v;
                             }
                         }
                     }
                     $data[$key] = $value;
                 }
             }
         }
     }
     ######################请求文件部分结束#####################
     //有生成缓存设置,生成缓存
     if ($this->hg_settings['cache_update']) {
         $cache_path = '';
         $cache_path = $this->hg_mobile_cache_path . $this->hg_mobile_ymd . '/';
         if (!is_dir($cache_path)) {
             hg_mkdir($cache_path);
         }
         if (is_array($data)) {
             $data = json_encode($data);
         }
         //生成缓存
         @file_put_contents($this->hg_mobile_cache, $data);
     }
     if (!$data) {
         $data = array();
     }
     //输出
     if (is_array($data)) {
         $data = json_encode($data);
     }
     echo $data;
 }
Ejemplo n.º 30
0
 public function build_comment_set_cache()
 {
     //查询各应用系统配置
     $sql = "SELECT * FROM " . DB_PREFIX . "app_settings WHERE content_id=0";
     $q = $this->db->query($sql);
     while ($r = $this->db->fetch_array($q)) {
         $arr[$r['var_name']] = unserialize($r['value']);
     }
     if ($arr && count($arr)) {
         if (!is_dir(MESSAGE_SET_CACHE_DIR)) {
             hg_mkdir(MESSAGE_SET_CACHE_DIR);
         }
         if (file_exists('../cache/comment_set_cache.php')) {
             unlink('../cache/comment_set_cache.php');
         }
         @file_put_contents(MESSAGE_SET_CACHE_DIR . 'comment_set_cache.php', "<?php\r\n");
         foreach ($arr as $k => $v) {
             @file_put_contents(MESSAGE_SET_CACHE_DIR . 'comment_set_cache.php', "\r\n\$gGlobalConfig['" . $k . "'] = " . var_export($v, true) . ";\n", FILE_APPEND);
         }
         @file_put_contents(MESSAGE_SET_CACHE_DIR . 'comment_set_cache.php', "\n?>", FILE_APPEND);
     }
 }