Beispiel #1
0
 private function doDir($dir = '')
 {
     if (!is_dir($dir)) {
         return false;
     }
     //解析输入的目录的最后一级
     $lastDirName = basename(rtrim($dir, '/'));
     if (!$lastDirName) {
         return false;
     }
     //判断upload目录里面的第一级存不存在所输入的目录名称
     if (is_dir(UPLOAD_DIR . $lastDirName)) {
         //随机产生一个目录名称
         $lastDirName = $lastDirName . TIMENOW . hg_rand_num(5);
     }
     //先将目录移动到upload目录
     $cmd = 'cp -r ' . $dir . ' ' . UPLOAD_DIR . $lastDirName;
     exec($cmd, $out, $status);
     //目录复制后删除原来目录
     if (!$status) {
         $cmd = 'rm -Rf ' . $dir;
         exec($cmd);
     }
     return $lastDirName;
 }
Beispiel #2
0
 /**
  * 获取裁剪的原图
  */
 public function get_ori_img()
 {
     //原头像图
     $file_name = $this->user['id'] . ".jpg";
     $path = AVATAR_URL . ceil($this->user['id'] / NUM_IMG) . "/" . $file_name . "?" . hg_rand_num(7);
     echo $path;
 }
Beispiel #3
0
 public function upload()
 {
     if (!$this->input['video_id']) {
         $this->errorOutput(NOID);
     }
     $sql = " SELECT video_base_path,video_path,video_filename,id FROM " . DB_PREFIX . "vodinfo WHERE id IN (" . $this->input['video_id'] . ")";
     $q = $this->db->query($sql);
     $video = array();
     while ($r = $this->db->fetch_array($q)) {
         $video[] = $r;
     }
     //实例化ftp,并连接
     $ftp_config = array('hostname' => $this->input['hostname'], 'username' => $this->input['username'], 'password' => $this->input['password']);
     $ftp = new Ftp();
     if (!$ftp->connect($ftp_config)) {
         $this->errorOutput('CAN NOT CONNECT FTP SERVER');
     }
     foreach ($video as $k => $v) {
         $target_dir = date('Y', TIMENOW) . '/' . date('m', TIMENOW) . '/' . TIMENOW . hg_rand_num(6) . '/';
         $target_path = $target_dir . $v['video_filename'];
         $video_filepath = $v['video_base_path'] . $v['video_path'] . $v['video_filename'];
         if (!$ftp->mkdir($target_dir)) {
             $this->errorOutput('CAN NOT MAKE DIR');
         }
         if (!$ftp->upload($video_filepath, $target_path)) {
             $this->errorOutput('CAN NOT UPLOAD FILE');
         }
         $pathinfo = pathinfo($target_path);
         $filename = basename($pathinfo['basename'], '.' . $pathinfo['extension']);
         $this->addItem(array('path' => $target_path, 'id' => $v['id'], 'dir' => $pathinfo['dirname'], 'filename' => $filename));
     }
     $this->output();
 }
Beispiel #4
0
 public function update()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     $update_data = array('name' => $this->input['name'], 'update_time' => TIMENOW);
     //如果传了图片
     if ($_FILES['water_pic']) {
         $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);
         }
         $add_data = array('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);
         //还要将原来图片文件删除掉
         $oldWter = $this->mode->detail($this->input['id']);
         if ($oldWter) {
             unlink($oldWter['base_path'] . $oldWter['img_path']);
         }
     }
     if ($add_data) {
         $update_data = array_merge($update_data, $add_data);
     }
     $ret = $this->mode->update($this->input['id'], $update_data);
     if ($ret) {
         $this->addLogs('更新水印', $ret, '', '更新水印' . $this->input['id']);
         $this->addItem('success');
         $this->output();
     }
 }
Beispiel #5
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();
 }
Beispiel #6
0
 private function getPlan($channel_id, $dates)
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "program_plan p LEFT JOIN " . DB_PREFIX . "program_plan_relation r ON r.plan_id=p.id WHERE 1 and p.channel_id=" . $channel_id . " AND r.week_num=" . date("N", strtotime($dates)) . " ORDER BY p.start_time ASC";
     $q = $this->db->query($sql);
     $program_plan = array();
     while ($r = $this->db->fetch_array($q)) {
         $program_plan[] = array('id' => hg_rand_num(10), 'channel_id' => $r['channel_id'], 'start_time' => strtotime($dates . " " . date("H:i:s", $r['start_time'])), 'toff' => $r['toff'], 'theme' => $r['program_name'], 'subtopic' => '', 'type_id' => 1, 'dates' => $dates, 'weeks' => date('W', strtotime($dates . " " . date("H:i:s", $r['start_time']))), 'describes' => '', 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'is_show' => 1, 'start' => date("H:i", strtotime($dates . " " . date("H:i:s", $r['start_time']))), 'end' => date("H:i", strtotime($dates . " " . date("H:i:s", $r['start_time'])) + $r['toff']), 'is_plan' => 1);
     }
     return $program_plan;
 }
Beispiel #7
0
 /**
  * 生成目录结构
  *
  * @access public
  * @param  无
  * @return array
  */
 public static function buildDirStruct($user_id = '')
 {
     $dirNames = TIMENOW . hg_rand_num(2);
     $dir = date('Y/m/d/', TIMENOW);
     if ($user_id) {
         $dir = $user_id . '/' . $dir;
     } else {
         $dir = 'system/' . $dir;
         //系统图标
     }
     return array($dirNames, $dir);
 }
Beispiel #8
0
 function getInfo($start, $end, $dates, $type = 0)
 {
     //$type 存在表示space color 存在,否 null存在
     $info = array('id' => hg_rand_num(10), 'name' => '新话题', 'dates' => $dates, 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end), 'channel_id' => $this->input['channel_id']);
     if ($type) {
         $info['color'] = '#DF6564,#FEF2F2';
         $info['space'] = 1;
     } else {
         $info['null'] = 1;
     }
     return $info;
 }
Beispiel #9
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();
 }
Beispiel #10
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();
 }
Beispiel #11
0
 public function detail()
 {
     $id = intval($this->input['id']);
     if (!$id) {
         $this->output();
     }
     if (!class_exists('programTemplate')) {
         include CUR_CONF_PATH . 'lib/program_template.class.php';
     }
     $objProTemplate = new programTemplate();
     $ret = $objProTemplate->getOneById($id);
     if (!empty($ret['data'])) {
         $date = date('Y-m-d');
         $noon = strtotime($date . ' 12:00');
         $program = array();
         if (is_array($ret['data']) && count($ret['data']) > 0) {
             foreach ($ret['data'] as $k => $v) {
                 $v['start_time'] = strtotime($data . ' ' . $v['start']);
                 if ($v['start_time'] < $noon) {
                     $v['pos'] = hg_get_pos($v['start_time'] - strtotime($date));
                     $v['slider'] = hg_get_slider($v['start_time'] - strtotime($date));
                     $key = 'am';
                 } else {
                     $v['pos'] = hg_get_pos($v['start_time'] - strtotime($date . " 12:00"));
                     $v['slider'] = hg_get_slider($v['start_time'] - strtotime($date . " 12:00"));
                     $key = 'pm';
                 }
                 $v['id'] = $v['key'] = hg_rand_num(4);
                 $program[$key][] = $v;
             }
             $ret['data'] = $program;
         }
     }
     if ($ret) {
         $this->addItem($ret);
     }
     $this->output();
 }
Beispiel #12
0
 * 活动报名
 * */
header('Content-Type:text/html; charset=utf-8');
define('M2O_ROOT_PATH', './');
require M2O_ROOT_PATH . 'global.php';
require_once M2O_ROOT_PATH . 'lib/class/http.class.php';
function show_message($message)
{
    if ($_SERVER['HTTP_REFERER']) {
        echo "<script>alert('" . $message . "');window.location.href='" . $_SERVER["HTTP_REFERER"] . "';</script>";
    } else {
        echo "<script>alert('" . $message . "')</script>";
    }
    exit;
}
$data = array();
if (!$_REQUEST['activityid'] || !$_REQUEST['type'] || !$_REQUEST['type_name']) {
    show_message('没有选择活动');
}
if (!$_REQUEST['nick_name']) {
    show_message('请填写姓名');
}
$data = array('type' => $_REQUEST['type'], 'type_name' => $_REQUEST['type_name'], 'platform_id' => uniqid() . hg_rand_num(), 'nick_name' => $_REQUEST['nick_name'], 'activityid' => $_REQUEST['activityid'], 'member_info' => $_REQUEST['member_info'], 'a' => 'login', 'appid' => APPID, 'appkey' => APPKEY);
$url = $gGlobalConfig['App_members']['protocol'] . $gGlobalConfig['App_members']['host'] . '/' . $gGlobalConfig['App_members']['dir'] . 'login.php';
$http = new Http();
$ret = $http->post($url, $data, false);
//print_r($ret);
if (empty($ret) || $ret['ErrorCode']) {
    show_message($ret['ErrorText']);
}
show_message('提交成功');
Beispiel #13
0
 public static function getOrderNumberByUserID($user_id = '')
 {
     return date('is', TIMENOW) . hg_rand_num(1) . $user_id . hg_rand_num(1);
 }
Beispiel #14
0
 /**
  * 获取该频道串联单计划信息
  * @name getPlan
  * @access private
  * @author lijiaying
  * @category hogesoft
  * @copyright hogesoft
  * @param $channel_id int 频道ID
  * @param $dates string 格式化日期(Y-m-d)
  * @return $change_plan array 该频道串联单计划信息内容
  */
 private function getPlan($channel_id, $dates)
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "change_plan p ";
     $sql .= " LEFT JOIN " . DB_PREFIX . "change_plan_relation r ON r.plan_id=p.id";
     $sql .= " WHERE 1 and p.channel_id=" . $channel_id . " AND r.week_num=" . date("N", strtotime($dates));
     $sql .= " ORDER BY p.start_time ASC";
     $q = $this->db->query($sql);
     $change_plan = array();
     while ($r = $this->db->fetch_array($q)) {
         $week_days = $r['week_days'];
         $week_d = date('N', strtotime($dates));
         $week = date('W', $r['program_start_time']);
         $this_week = date('W', TIMENOW);
         $offset_week = ($this_week - $week) * 24 * 3600 * 7;
         if ($week_days == $week_d) {
             $program_start_time = date('Y-m-d H:i:s', $r['program_start_time'] + $offset_week);
         } else {
             if ($week_days > $week_d) {
                 $program_start_time = date('Y-m-d H:i:s', $r['program_start_time'] - 86400 * ($week_days - $week_d) + $offset_week);
             } else {
                 if ($week_days < $week_d) {
                     $program_start_time = date('Y-m-d H:i:s', $r['program_start_time'] + 86400 * ($week_d - $week_days) + $offset_week);
                 }
             }
         }
         $change_plan[] = array('id' => hg_rand_num(12), 'channel_id' => $r['channel_id'], 'change_time' => strtotime($dates . " " . date("H:i:s", $r['start_time'])), 'toff' => $r['toff'], 'file_toff' => time_format($r['file_toff']), 'stream_uri' => $r['stream_uri'], 'channel2_id' => $r['channel2_id'], 'channel2_name' => $r['channel2_name'], 'program_end_time' => $r['program_start_time'] ? date('Y-m-d H:i:s', strtotime($program_start_time) + $r['toff']) : '', 'program_start_time' => $r['program_start_time'] ? $program_start_time : '', 'week_days' => $r['week_days'], 'type' => $r['type'], 'dates' => $dates, 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'end_time' => date("H:i:s", $r['start_time'] + $r['toff']), 'start_time' => date("H:i:s", $r['start_time']), 'e_time' => $r['program_start_time'] ? date('H:i:s', strtotime($program_start_time) + $r['toff']) : '', 's_time' => $r['program_start_time'] ? date('m-d H:i:s', strtotime($program_start_time)) : '', 'is_plan' => 1);
     }
     return $change_plan;
 }
Beispiel #15
0
 private function getInfo($start, $end, $dates, $new = 1, $type = 0)
 {
     $toff = $end - $start;
     if ($end - $start > 3600) {
         $toff = 3600;
     }
     $info = array('id' => hg_rand_num(10), 'channel_id' => $this->input['channel_id'], 'start_time' => $start, 'toff' => $toff, 'theme' => '精彩节目', 'subtopic' => '', 'type_id' => 1, 'dates' => $dates, 'weeks' => date('W', $start), 'describes' => '', 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'is_show' => 1, 'color' => '#DF6564,#FEF2F2', 'start' => date("H:i", $start), 'end' => date("H:i", $start + $toff), 'week_set' => date('W', $start), 'item' => 0, 'new' => $new, 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'org_id' => $this->user['org_id'], 'appid' => $this->user['appid'], 'appname' => $this->user['appname']);
     if ($start <= TIMENOW) {
         $info['outdate'] = 1;
     } else {
         $info['outdate'] = 0;
     }
     if ($type) {
         $info['space'] = 1;
     }
     return $info;
 }
Beispiel #16
0
/**
 * 生成兑换码
 */
function generateExchangeCode()
{
    return substr(TIMENOW, -4) . substr(microtime(), 2, 4) . hg_rand_num(2);
}
Beispiel #17
0
     //发送邮件
     if (!$this->sendActivateEmail($user_info, $this->input['new_email'])) {
         $this->errorOutput(EMAIL_SEND_FAIL);
     }
     $this->addItem(array('return' => 1));
     $this->output();
 }
 /***************************************修改某人的邮箱,只针对没有激活的邮箱***************************************/
 /***************************************修改某人的邮箱,正常的修改***********************************************/
 public function changeEmail()
 {
     $user_id = $this->user['user_id'];
     $new_email = trim($this->input['new_email']);
     if (!$user_id) {
         $this->errorOutput(NO_LOGIN);
     }
     //查询出该人的信息
     $user_info = $this->dingdone_mode->getUserByCond(" AND id = '" . $user_id . "'");
     if (!$user_info) {
         $this->errorOutput(THIS_USER_NOT_EXISTS);
     }
     //邮箱不存在,报错
     if (!$new_email) {
         $this->errorOutput(NO_EMAIL);
     } elseif ($new_email == $user_info['email']) {
         $this->errorOutput(THE_NEW_EMAIL_IS_SAME_TO_OLD);
     } elseif ($_isExistEmail = $this->dingdone_mode->getUserByCond(" AND email = '" . $new_email . "' AND id != '" . $user_id . "' ")) {
         $this->errorOutput(THIS_EMAIL_HAS_EXISTS);
     }
Beispiel #18
0
 private function mkAuthCode()
 {
     $this->code = hg_rand_num(6);
 }
Beispiel #19
0
 private function create_vcard_pic($_vcard_data = array())
 {
     if (!$_vcard_data || empty($_vcard_data)) {
         return false;
     }
     $_pic_name = md5(TIMENOW . hg_rand_num(6)) . '.png';
     //随机产生图片文件名
     if (!hg_mkdir(VCARD_DIR) || !is_writeable(VCARD_DIR)) {
         $this->errorOutput(NO_WRITE);
     }
     QRcode::png(json_encode($_vcard_data), VCARD_DIR . $_pic_name);
     return $_pic_name;
 }
Beispiel #20
0
 public function importMemberData2()
 {
     if (!$this->input['market_id']) {
         $this->errorOutput(NOID);
     }
     //首先将上传上来的excel文件放到data目录
     if (!$_FILES['excelfile']['tmp_name']) {
         $this->errorOutput(NO_FILE);
     }
     $original = urldecode($_FILES['excelfile']['name']);
     $filetype = strtolower(strrchr($original, '.'));
     if (!in_array($filetype, array('.xlsx', '.xls'))) {
         $this->errorOutput('此文件格式不支持');
     }
     $name = date('Y-m-d', TIMENOW) . '-' . TIMENOW . hg_rand_num(6);
     $filename = $name . $filetype;
     $filepath = DATA_DIR . 'excel/';
     if (!hg_mkdir($filepath) || !is_writeable($filepath)) {
         $this->errorOutput(NOWRITE);
     }
     if (!@move_uploaded_file($_FILES['excelfile']['tmp_name'], $filepath . $filename)) {
         $this->errorOutput(FAIL_MOVE);
     }
     //上传成功之后就初始化数据,将excel数据读入缓存文件中
     $PHPExcelInfo = new PHPExcelInfo($filepath . $filename);
     $memberInfo = $PHPExcelInfo->getData();
     $dataPath = $filepath . $name . '.json';
     file_put_contents($dataPath, json_encode($memberInfo));
     if ($memberInfo) {
         @unlink($filepath . $filename);
         $taskPath = DATA_DIR . 'excel/task.k';
         if (file_exists($taskPath)) {
             $task = file_get_contents($taskPath);
             $task = unserialize($task);
         } else {
             $task = array();
         }
         $task[] = array('filename' => $dataPath, 'market_id' => $this->input['market_id'], 'name' => $original);
         file_put_contents($taskPath, serialize($task));
         $this->addItem('success');
         $this->output();
     }
 }
Beispiel #21
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);
 }
Beispiel #22
0
 public function export_file()
 {
     $ids = $this->input['id'];
     if (!$ids) {
         $this->errorOutput('id不存在');
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "mobile_deploy WHERE id IN (" . $ids . ")";
     $q = $this->db->query($sql);
     $data = array();
     while ($r = $this->db->fetch_array($q)) {
         $data[] = $r;
     }
     if (!empty($data)) {
         $filepath = DATA_DIR;
         if (!hg_mkdir($filepath) || !is_writeable($filepath)) {
             $this->errorOutput(NOWRITE);
         }
         $json = json_encode($data);
         $filename = date('Y-m-d', TIMENOW) . '-' . TIMENOW . hg_rand_num(6) . '.json';
         @file_put_contents($filepath . $filename, $json);
         //$file = @fopen($filepath . $filename,"r");
         Header("Content-type: application/octet-stream");
         Header("Accept-Ranges: bytes");
         Header("Accept-Length: " . filesize($filepath . $filename));
         $file_name = date('Y-m-d-H-i-s') . '.json';
         Header("Content-Disposition: attachment; filename=" . $file_name);
         // 输出文件内容
         $timeout = array('http' => array('timeout' => 10));
         $ctx = stream_context_create($timeout);
         echo file_get_contents($filepath . $filename, 0, $ctx);
         //echo fread($file,filesize($filepath . $filename));
         //fclose($file);
         unlink($filepath . $filename);
         exit;
     }
 }
Beispiel #23
0
 public function export_file()
 {
     $sort_id = intval($this->input['sort_id']);
     if (!$sort_id) {
         $this->errorOutput('分类Id不存在');
     }
     $sort_dir = $this->input['sort_dir'];
     if (!$sort_dir) {
         $sql = "SELECT sort_dir FROM " . DB_PREFIX . "mobile_sort WHERE id = " . $sort_id;
         $res = $this->db->query($sql);
         $sort_dir = $res['sort_dir'];
     }
     if (!$sort_dir) {
         $this->errorOutput('sort_dir不存在');
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "mobile_deploy WHERE sort_id = " . $sort_id;
     $q = $this->db->query($sql);
     while ($r = $this->db->fetch_array($q)) {
         $data[] = $r;
     }
     if ($data) {
         $filepath = DATA_DIR . $sort_dir;
         if (!hg_mkdir($filepath) || !is_writeable($filepath)) {
             $this->errorOutput(NOWRITE);
         }
         $json = json_encode($data);
         $filename = date('Y-m-d', TIMENOW) . '-' . TIMENOW . hg_rand_num(6) . '.json';
         @file_put_contents($filepath . $filename, $json);
         $file = @fopen($filepath . $filename, "r");
         Header("Content-type: application/octet-stream");
         Header("Accept-Ranges: bytes");
         Header("Accept-Length: " . filesize($filepath . $filename));
         $file_name = substr($sort_dir, 0, -1) . '_export_file.json';
         Header("Content-Disposition: attachment; filename=" . $file_name);
         // 输出文件内容
         echo fread($file, filesize($filepath . $filename));
         fclose($file);
         unlink($filepath . $filename);
         exit;
     }
 }
Beispiel #24
0
function create_video_dir()
{
    $vod_dir_names = TIMENOW . hg_rand_num(2);
    $video_dir = date('Y', TIMENOW) . '/' . hg_split_num($vod_dir_names, 4, '/') . $vod_dir_names . '.ssm/';
    if (file_exists(UPLOAD_DIR . $video_dir) || file_exists(TARGET_DIR . $video_dir)) {
        return create_video_dir();
    }
    return array($vod_dir_names, $video_dir);
}
Beispiel #25
0
 private function getInfo($start, $end, $dates, $channel_id = 0)
 {
     $info = array('id' => hg_rand_num(10), 'channel_id' => $channel_id, 'start_time' => $start, 'toff' => $end - $start, 'theme' => '精彩节目', 'subtopic' => '', 'type_id' => 1, 'dates' => $dates, 'weeks' => date('W', $start), 'describes' => '', 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'is_show' => 1, 'start' => date("H:i", $start), 'end' => date("H:i", $end), 'display' => $display, 'now_display' => $now_display);
     return $info;
 }
 public function lead_file()
 {
     $sort_id = intval($this->input['sort_id']);
     if (!$sort_id) {
         $this->errorOutput('分类id不存在');
     }
     $sort_dir = $this->input['sort_dir'];
     if (!$sort_dir) {
         $sql = "SELECT sort_dir FROM " . DB_PREFIX . "mobile_sort WHERE id = " . $sort_id;
         $res = $this->db->query($sql);
         $sort_dir = $res['sort_dir'];
     }
     if (!$sort_dir) {
         $this->errorOutput('sort_dir不存在');
     }
     if (!$_FILES['filedata']['tmp_name']) {
         $this->errorOutput(NO_FILE);
     }
     $original = urldecode($_FILES['filedata']['name']);
     $filetype = strtolower(strrchr($original, '.'));
     if (!in_array($filetype, array('.json'))) {
         $this->errorOutput('此文件格式不支持');
     }
     $name = date('Y-m-d', TIMENOW) . '-' . TIMENOW . hg_rand_num(6);
     $filename = $name . $filetype;
     $filepath = DATA_DIR . $sort_dir;
     if (!hg_mkdir($filepath) || !is_writeable($filepath)) {
         $this->errorOutput(NOWRITE);
     }
     if (!@move_uploaded_file($_FILES['filedata']['tmp_name'], $filepath . $filename)) {
         $this->errorOutput(FAIL_MOVE);
     }
     $json = @file_get_contents($filepath . $filename);
     if ($json) {
         $data = json_decode($json, 1);
         if (!$data) {
             return false;
         }
         //模板文件路径
         if (!defined('MOBILE_API_TPL')) {
             define('MOBILE_API_TPL', '../api/apitpl.php');
         }
         $tpl = MOBILE_API_TPL;
         //获取模板文件
         $tpl_str = @file_get_contents($tpl);
         foreach ($data as $val) {
             if (empty($val)) {
                 continue;
             }
             unset($val['id']);
             $val['sort_id'] = $sort_id;
             $sql = "INSERT INTO " . DB_PREFIX . "mobile_deploy SET ";
             foreach ($val as $k => $v) {
                 $sql .= '`' . $k . "`='" . $v . "',";
             }
             $sql = rtrim($sql, ',');
             $this->db->query($sql);
             if ($tpl_str) {
                 $val['sort_dir'] = $sort_dir;
                 mobile_build_file($val, $tpl_str);
             }
         }
         unlink($filepath . $filename);
         $this->addItem('success');
     }
     $this->output();
 }
Beispiel #27
0
 /**
  * 头像生成接口
  * @return array  头像地址
  */
 public function uploadImage()
 {
     if (!$this->input['user_id']) {
         $userinfo = $this->mUser->verify_credentials();
     } else {
         $userinfo['id'] = intval($this->input['user_id']);
     }
     if (!$userinfo['id']) {
         $this->errorOutput(USENAME_NOLOGIN);
     }
     $files = $_FILES['files'];
     include_once ROOT_DIR . 'lib/class/gdimage.php';
     //源文件
     $uploadedfile = $files['tmp_name'];
     //源文件类型
     $tmp = explode('.', $uploadedfile);
     $file_type = $tmp[1];
     //文件名
     $file_name = $userinfo['id'] . ".jpg";
     //目录
     $file_dir = AVATAR_DIR . ceil($userinfo['id'] / NUM_IMG) . "/";
     //文件路径
     $file_path = $file_dir . $file_name;
     $size = array("larger" => array(LARGER_IMG_WIDTH, LARGER_IMG_HEIGHT), "middle" => array(MIDDLE_IMG_WIDTH, MIDDLE_IMG_HEIGHT), "small" => array(SMALL_IMG_WIDTH, SMALL_IMG_HEIGHT));
     if (!hg_mkdir($file_dir)) {
         $this->errorOutput(UPLOAD_ERR_NO_FILE);
     }
     if (!move_uploaded_file($uploadedfile, $file_path)) {
         $this->errorOutput(UPLOAD_ERR_NO_FILE);
     }
     //如果传递了裁剪信息
     if ($this->input['cut_info']) {
         $cut_info = urldecode($this->input['cut_info']);
         $info = explode(',', $cut_info);
         //裁剪的起点坐标
         $src_x = $info[0];
         $src_y = $info[1];
         //裁剪图片的大小
         $src_w = $info[2];
         $src_h = $info[3];
         $src_img = imagecreatefromjpeg($file_path);
         $dst_img = imageCreateTrueColor($src_w, $src_h);
         imageCopy($dst_img, $src_img, 0, 0, $src_x, $src_y, $src_w, $src_h);
         imageJPEG($dst_img, $file_path, 100);
     }
     $img = new GDImage($file_path, $file_path, '');
     $info = array();
     foreach ($size as $key => $value) {
         $save_file_path = $file_dir . $key . '_' . $file_name;
         $img->init_setting($file_path, $save_file_path, '');
         $img->maxWidth = $value[0];
         $img->maxHeight = $value[1];
         $img->makeThumb(3, false);
         $info[$key] = AVATAR_URL . ceil($userinfo['id'] / NUM_IMG) . "/" . $key . '_' . $file_name . "?" . hg_rand_num(7);
     }
     $info['ori'] = AVATAR_URL . ceil($userinfo['id'] / NUM_IMG) . "/" . $file_name . "?" . hg_rand_num(7);
     $sql = "UPDATE " . DB_PREFIX . "member \r\n\t\tSET avatar = '" . $userinfo['id'] . ".jpg' \r\n\t\tWHERE id=" . $userinfo['id'];
     $this->db->query($sql);
     $info['id'] = $userinfo['id'];
     $this->setXmlNode('img', 'imagefile');
     $this->addItem($info);
     return $this->output();
 }
Beispiel #28
0
                }
            }
            ?>
							</li>
							<li>
							<?php 
            if (is_array($video)) {
                ?>
									<ul class="pre" id="pre_<?php 
                echo $v['id'];
                ?>
">
									<?php 
                $j = 1;
                foreach ($video as $ks => $vs) {
                    $salt = hg_rand_num(2);
                    ?>
										<li>
											<div id="pres_<?php 
                    echo $vs['id'] + $vs['programe_id'] + $salt;
                    ?>
" style="position: relative;padding:5px 0;width:122px">
												<img src="<?php 
                    echo $vs['schematic'];
                    ?>
"/>
												<a href="javascript:void(0);" onclick="scaleVideo(<?php 
                    echo $vs['id'] + $vs['programe_id'] + $salt;
                    ?>
,<?php 
                    echo $v['id'];
Beispiel #29
0
 private function getInfo($start, $end, $dates, $channel_id, $type = 0, $new = 1)
 {
     $info = array('id' => hg_rand_num(10), 'channel_id' => $channel_id, 'start_time' => $start, 'toff' => $end - $start, 'theme' => '精彩节目', 'subtopic' => '', 'type_id' => 1, 'dates' => $dates, 'weeks' => date('W', $start), 'describes' => '', 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'ip' => hg_getip(), 'is_show' => 1, 'color' => '#DF6564,#FEF2F2', 'start' => date("H:i", $start), 'end' => date("H:i", $end), 'week_set' => date('W', $start), 'item' => 0, 'new' => $new);
     if ($start <= TIMENOW) {
         $info['outdate'] = 1;
     } else {
         $info['outdate'] = 0;
     }
     if ($type) {
         $info['space'] = 1;
     }
     return $info;
 }
Beispiel #30
0
 private function get_program($channel_id, $dates)
 {
     $condition = " AND channel_id=" . $channel_id;
     $condition .= " AND dates='" . $dates . "'";
     //该频道的录播记录
     $sql = "select *,FROM_UNIXTIME(start_time, '%Y-%m-%d') as start,FROM_UNIXTIME(start_time, '%U') as week_set from " . DB_PREFIX . "program ";
     $sql .= ' where 1 ' . $condition . ' ORDER BY start_time ASC';
     $q = $this->db->query($sql);
     $program = array();
     $key = '';
     $noon = strtotime($dates . " 12:00");
     while ($row = $this->db->fetch_array($q)) {
         $row['start'] = date("H:i", $row['start_time']);
         $row['end'] = date("H:i", $row['start_time'] + $row['toff']);
         if ($row['start_time'] <= TIMENOW) {
             $row['outdate'] = 1;
         } else {
             $row['outdate'] = 0;
         }
         if ($row['start_time'] <= $noon) {
             $row['pos'] = hg_get_pos($row['start_time'] - strtotime($dates));
             $row['slider'] = hg_get_slider($row['start_time'] - strtotime($dates));
             $key = 'am';
         } else {
             $row['pos'] = hg_get_pos($row['start_time'] - strtotime($dates . " 12:00"));
             $row['slider'] = hg_get_slider($row['start_time'] - strtotime($dates . " 12:00"));
             $key = 'pm';
         }
         $row['key'] = hg_rand_num(4);
         $program[$key][] = $row;
     }
     return $program;
 }