本文整理汇总了PHP中hg_cutchars函数的典型用法代码示例。如果您正苦于以下问题:PHP hg_cutchars函数的具体用法?PHP hg_cutchars怎么用?PHP hg_cutchars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hg_cutchars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show()
{
$offset = $this->input['offset'] ? $this->input['offset'] : 0;
$count = $this->input['count'] ? intval($this->input['count']) : 20;
$condition = $this->get_condition();
$orderby = ' ORDER BY t1.order_id DESC,t1.id DESC ';
$limit = ' LIMIT ' . $offset . ' , ' . $count;
$ret = $this->mode->show($condition, $orderby, $limit);
$size = '270x170/';
if (!empty($ret)) {
foreach ($ret as $k => $v) {
if ($v['title']) {
$v['title'] = hg_cutchars($v['title'], 8);
}
if ($v['start_time'] > TIMENOW) {
$v['cheap_status'] = '未开始';
$v['cheap_color'] = 0;
} else {
if ($v['start_time'] < TIMENOW && $v['end_time'] > TIMENOW) {
$v['cheap_status'] = '进行中';
$v['cheap_color'] = 1;
} else {
if ($v['end_time'] < TIMENOW) {
$v['cheap_status'] = '已结束';
$v['cheap_color'] = 2;
}
}
}
$v['time_now'] = TIMENOW;
$v['indexpic_url'] = hg_material_link($v['host'], $v['dir'], $v['filepath'], $v['filename'], $size);
$this->addItem($v);
}
$this->output();
}
}
示例2: show
/**
*
* 视频数据获取默认方法
*/
public function show()
{
$ret = array();
if ($this->input['cid']) {
/*查询出该频道的信息*/
$sql = "SELECT n.* , u.username FROM " . DB_PREFIX . "network_station AS n LEFT JOIN " . DB_PREFIX . "user AS u ON n.user_id = u.id WHERE n.id = '" . intval($this->input['cid']) . "'";
$arr = $this->db->query_first($sql);
//如果存在LOGO
if ($arr['logo']) {
$arr['logo_url'] = UPLOAD_URL . LOGO_DIR . ceil($arr['user_id'] / NUM_IMG) . "/" . $arr['logo'];
} else {
$arr['logo_url'] = UPLOAD_URL . LOGO_DIR . "0.gif";
}
$arr['brief'] = hg_cutchars($arr['brief'], 21);
$arr['create_time'] = date('Y-m-d', $arr['create_time']);
$arr['update_time'] = date('Y-m-d', $arr['update_time']);
$ret['channel'] = $arr;
}
//分页参数设置
$offset = $this->input['offset'] ? $this->input['offset'] : 0;
$count = $this->input['count'] ? intval($this->input['count']) : 24;
$data_limit = ' LIMIT ' . $offset . ' , ' . $count;
$sql = "SELECT v.* , u.username FROM " . DB_PREFIX . "video AS v LEFT JOIN " . DB_PREFIX . "user AS u ON v.user_id = u.id WHERE 1 ";
//获取查询条件
$condition = $this->get_condition();
$sql = $sql . $condition . $data_limit;
$q = $this->db->query($sql);
$this->setXmlNode('video_info', 'video');
while ($row = $this->db->fetch_array($q)) {
$row['title'] = hg_cutchars($row['title'], 8);
$row['create_time'] = date('Y-m-d H:i:s', $row['create_time']);
$row['update_time'] = date('Y-m-d H:i:s', $row['update_time']);
$row['toff'] = date('i:s', $row['toff']);
$row['state_tags'] = $this->settings['video_state'][$row['state']];
if ($this->settings['rewrite']) {
$row['link'] = SNS_VIDEO . "video-" . $row['id'] . ".html";
} else {
$row['link'] = SNS_VIDEO . "video_play.php?id=" . $row['id'];
}
switch (intval($row['is_show'])) {
case 0:
$row['audit'] = 0;
break;
case 1:
$row['audit'] = 0;
break;
case 2:
$row['audit'] = 1;
break;
default:
break;
}
$row['is_show_tags'] = $this->settings['video_type'][$row['is_show']];
$row['copyright'] = $this->settings['video_copyright'][$row['copyright']];
$ret['video'][] = $row;
}
$this->addItem($ret);
$this->output();
}
示例3: create
public function create()
{
$data = array('title' => trim($this->input['title']), 'subtitle' => trim($this->input['subtitle']), 'keywords' => str_replace(' ', ',', trim($this->input['keywords'])), 'brief' => trim($this->input['brief']), 'author' => trim($this->input['author']), 'source' => trim($this->input['source']), 'sort_id' => intval($this->input['sort_id']), 'appid' => intval($this->user['appid']), 'appname' => trim($this->user['display_name']), 'indexpic' => trim($this->input['indexpic']), 'pic' => trim($this->input['pic']), 'video' => trim($this->input['video']), 'material_ids' => trim($this->input['material_ids']), 'source_url' => trim($this->input['source_url']), 'create_time' => TIMENOW, 'org_id' => $this->user['org_id'], 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'ip' => hg_getip(), 'update_time' => TIMENOW);
$content = trim($this->input['content']);
if (!$content) {
$this->errorOutput("内容不能为空");
}
$data['title'] = $data['title'] ? $data['title'] : hg_cutchars($content, 20);
$d_forward = array();
//记录直接转发数据
//获取转发配置
if ($data['sort_id']) {
$set_id = array();
$config = $this->gather->get_config_by_sortId($data['sort_id']);
if ($config[$data['sort_id']] && is_array($config[$data['sort_id']])) {
foreach ($config[$data['sort_id']] as $val) {
$set_id[$val['id']] = $val['app_name'];
if ($val['is_open'] && $val['is_relay']) {
$d_forward[] = $val['id'];
}
}
}
if (!empty($set_id)) {
$data['set_id'] = serialize($set_id);
}
}
//插入主表
$id = $this->gather->insert_gather($data);
//插入内容表
$ret = $this->gather->insert_content($content, $id);
$data['id'] = $id;
$data['content'] = $ret;
//有直接转发数据插入直接转发队列
if (!empty($d_forward)) {
if (!$this->input['is_plan']) {
$res = $this->forward->forward($id);
if ($res && $res[$id]) {
$set_url = serialize($res[$id]);
$this->gather->update_set_url($set_url, $id);
}
} else {
foreach ($d_forward as $setid) {
$this->gather->insert_gather_plan($id, $setid);
}
}
}
$this->addItem($data);
$this->output();
}
示例4: hg_build_link
break;
case 7:
break;
default:
$style = ' class="cus_pad"';
break;
}
{/code}
<li{$style}><a title="{$value['username']}" href="<?php
echo hg_build_link("user.php", array('user_id' => $value['id']));
?>
"><img src="{$value['middle_avatar']}" width="50" height="50" /></a><a title="{$value['username']}" href="<?php
echo hg_build_link("user.php", array('user_id' => $value['id']));
?>
"><?php
echo hg_cutchars($value['username'], 4, " ");
?>
</a></li>
{code}
$i++;
{/code}
{/foreach}
</ul>
{/if}
</div>
<div class="g_bre3"></div>
<div style="text-align:center;">
{code}
echo hg_advert('google_2');
echo hg_advert('baidu_1');
{/code}
示例5: hg_build_link
$null_text = "暂未上传视频";
$null_type = 1;
$null_url = $_SERVER['HTTP_REFERER'];
{/code}
{template:unit/null}
{else}
<ul class="video">
{foreach $video as $key => $value}
<li class="cus_pad"><a target="_blank" href="<?php
echo hg_build_link(SNS_VIDEO . "video_play.php", array('id' => $value['id']));
?>
"><img title="{$value['title']}" src="{$value['schematic']}" width="144" height="108" /></a><a title="{$value['title']}" target="_blank" href="<?php
echo hg_build_link(SNS_VIDEO . "video_play.php", array('id' => $value['id']));
?>
"><?php
echo hg_cutchars($value['title'], 10, ' ');
?>
</a><span class="txt">播放:<strong>{$value['play_count']}</strong></span><span class="txt">评论:<strong>{$value['comment_count']}</strong></span></li>
{/foreach}
</ul>
<div class="clear"></div>
{/if}
{$showpages}
<div class="clear"></div>
</div>
<div class="con_bottom clear"></div>
</div>
</div>
{template:unit/my_right_menu}
</div>
{template:foot}
示例6: create
public function create()
{
//添加爆料主表
$data = array('title' => addslashes(trim($this->input['title'])), 'brief' => addslashes(trim($this->input['brief'])), 'appid' => $this->user['appid'], 'client' => $this->user['display_name'], 'longitude' => trim($this->input['longitude']), 'latitude' => trim($this->input['latitude']), 'create_time' => TIMENOW, 'user_id' => $this->input['user_name'] ? 0 : $this->user['user_id'], 'user_name' => addslashes($this->input['user_name']) ? addslashes($this->input['user_name']) : addslashes($this->user['user_name']), 'audit' => 1, 'sort_id' => trim(urldecode($this->input['sort_id'])));
$content = addslashes(trim(urldecode($this->input['content'])));
if (!$content) {
$this->errorOutput('请输入投稿内容');
}
if (!$data['sort_id']) {
$data['sort_id'] = 0;
} else {
//获取该分类下的发布栏目
$sortInfor = $this->con->getSortInfor($data['sort_id']);
if (!empty($sortInfor)) {
$data['column_id'] = addslashes($sortInfor[$data['sort_id']]['column_id']);
}
}
if (!$data['title']) {
$data['title'] = hg_cutchars($content, 20);
}
if (!$data['brief']) {
$data['brief'] = hg_cutchars($content, 100);
}
$contribute_id = $this->con->add_content($data);
//添加内容表
$body = array('id' => $contribute_id, 'text' => $content);
$this->con->add_contentbody($body);
//用户信息
$userinfo = array();
$userinfo = array('con_id' => intval($contribute_id), 'tel' => $this->input['tel'], 'email' => addslashes($this->input['email']), 'addr' => addslashes($this->input['addr']));
if ($this->input['user_name']) {
$userinfo = array('con_id' => intval($contribute_id), 'tel' => $this->input['tel'], 'email' => addslashes($this->input['email']), 'addr' => addslashes($this->input['addr']));
} elseif ($this->user['user_id'] && !$this->input['user_name']) {
$return = $this->con->get_userinfo_by_id($this->user['user_id']);
if (!empty($return)) {
$userinfo = array('con_id' => intval($contribute_id), 'tel' => $return['mobile'], 'email' => $return['email'], 'addr' => $return['address']);
}
}
if (!empty($userinfo)) {
$this->con->user_info($userinfo);
}
//图片上传
if ($_FILES['photos']) {
$count = count($_FILES['photos']['error']);
for ($i = 0; $i < $count; $i++) {
if ($_FILES['photos']['error'][$i] == 0) {
$pics = array();
foreach ($_FILES['photos'] as $k => $v) {
$pics['Filedata'][$k] = $_FILES['photos'][$k][$i];
}
//插入图片服务器
$ret = $this->con->uploadToPicServer($pics, $contribute_id);
//准备入库数据
$arr = array('content_id' => $contribute_id, 'mtype' => $ret['type'], 'original_id' => $ret['id'], 'host' => $ret['host'], 'dir' => $ret['dir'], 'material_path' => $ret['filepath'], 'pic_name' => $ret['filename']);
$id = $this->con->upload($arr);
//默认第一张图片为索引图
if (!$indexpic) {
$indexpic = $this->con->update_indexpic($id, $contribute_id);
}
}
}
}
//视频上传
if ($_FILES['videofile']) {
//上传视频服务器
$videodata = $this->con->uploadToVideoServer($_FILES, $data['title'], $data['brief']);
//有视频没有图片时,将视频截图上传作为索引图
if (!$indexpic) {
$url = $videodata['img']['host'] . $videodata['img']['dir'] . $videodata['img']['filepath'] . $videodata['img']['filename'];
$material = $this->con->localMaterial($url, $contribute_id);
$arr = array('content_id' => $contribute_id, 'mtype' => $material['type'], 'original_id' => $material['id'], 'host' => $material['host'], 'dir' => $material['dir'], 'material_path' => $material['filepath'], 'pic_name' => $material['filename']);
$indexpic = $this->con->upload($arr);
$this->con->update_indexpic($indexpic, $contribute_id);
}
//视频入库
$arr = array('content_id' => $contribute_id, 'mtype' => $videodata['type'], 'host' => $videodata['protocol'] . $videodata['host'], 'dir' => $videodata['dir'], 'vodid' => $videodata['id'], 'filename' => $videodata['file_name']);
$this->con->upload($arr);
}
//转发爆料
if ($contribute_id) {
$this->con->send_contribute($contribute_id, $flag = 1);
}
$this->addItem($contribute_id);
$this->output();
}
示例7: get_album_video
/**
* 获得专辑中的视频
* @param $album_id
* @param $page
* @param $count
* @return $ret 专辑信息
*/
public function get_album_video()
{
$count = $this->count;
$page = $this->page;
$album_id = $this->input['album_id'] ? $this->input['album_id'] : 0;
$disabled = $this->input['album_video'] ? '' : 'disabled';
$html = '';
if (!$album_id) {
$html = '';
} else {
$album_video = $this->mVideo->get_album_video($album_id, $page, $count);
$html = '<h3>
<a href="javascript:void(0);" onclick="edit_album_info(' . $album_video['id'] . ');">修改专辑信息</a> <a target="_blank" href="user_album_video.php?id=' . $album_video['id'] . '&user_id=' . $album_video['user_id'] . '">播放专辑</a>
<input type="hidden" id="album_id" value="' . $album_video['id'] . '"/>
<input type="hidden" id="album_name" value="' . $album_video['name'] . '"/>
<input type="hidden" id="album_brief" value="' . $album_video['brief'] . '"/>
<input type="hidden" id="album_sort" value="' . $album_video['sort_id'] . '"/>
<input type="hidden" id="album_total" value="' . $album_video['video']['total'] . '"/>
<span class="blod">专辑:<a title="' . $album_video['name'] . '" style="color: #000000; cursor: pointer; float: none; padding: 0; text-decoration: none;">' . hg_cutchars($album_video['name'], 8, " ") . '</a></span>
<span style="margin-left:30px;">共' . ($album_video['video']['total'] ? $album_video['video']['total'] : 0) . '个视频</span>
</h3><div class="show_info_tips show_info">';
if ($album_video) {
$data['totalpages'] = $album_video['video']['total'];
unset($album_video['video']['total']);
$data['perpage'] = $count;
$data['curpage'] = $this->input['pp'];
$data['onclick'] = 'onclick="album_page_show(this,4);"';
$showpages = hg_build_pagelinks($data);
}
$html .= '<div class="video_cp clear"><input type="button" value="添加视频" onclick="add_album_video(' . $album_id . ');"/><input name="get" type="button" onclick="del_album_video();" value="删除视频" ' . $disabled . '/><input name="get" onclick="move_album_show(' . $album_id . ');" type="button" value="移动到专辑" ' . $disabled . '/>
' . $showpages . '</div>
<div class="video_list" id="video_list clear">
<table width="100%" cellspacing=0 cellpadding=0>
<tr><th width="100px">序号</th><th>视频名称</th><th>添加时间</th><th>会员</th><th>播放次数</th><th>管理</th></tr>
';
if ($album_video['video'] && is_array($album_video['video'])) {
$i = 1;
foreach ($album_video['video'] as $key => $value) {
$tr .= '<tr>
<td width="100px"><input name="vch" type="checkbox" value="' . $value['id'] . '" onclick="check_list(this,4);"/>' . $i . '</td>
<td><a target="_blank" title="' . $value['title'] . '" href="' . hg_build_link('video_play.php', array('id' => $value['id'])) . '"><img src="' . $value['schematic'] . '"/></a>
<a target="_blank" title="' . $value['title'] . '" href="' . hg_build_link('video_play.php', array('id' => $value['id'])) . '">' . hg_cutchars($value['title'], 6, " ") . '</a>
</td>
<td>' . $value['create_time'] . '</td>
<td><a target="_blank" title="' . $value['user']['username'] . '" href="' . hg_build_link('user.php', array('id' => $value['user']['id'])) . '">' . hg_cutchars($value['user']['username'], 5, " ") . '</a></td>
<td>' . $value['play_count'] . '</td>
<td>
<a href="javascript:void(0);" onclick="edit_album_cover(' . $value['id'] . ',' . $album_video['id'] . ');">设为封面</a>|<a href="javascript:void(0);" onclick="del_album_video(' . $value['id'] . ');">移除</a>
</td>
</tr>';
$i++;
}
}
$html .= $tr . '</table>
</div>
<div><a class="f_r" onclick="return_album();" href="javascript:void(0);">返回列表</a></div>
<div class="video_cp clear"><input type="button" value="添加视频" onclick="add_album_video(' . $album_id . ');"/><input name="get" type="button" onclick="del_album_video();" value="删除视频" ' . $disabled . '/><input name="get" type="button" onclick="move_album_show(' . $album_id . ');" value="移动到专辑" ' . $disabled . '/>' . $showpages . '</div>
</div>';
}
echo $html;
exit;
}
示例8: hg_build_link
<div class="right_window con-left">
<div id="album_info" class="station_content">
<h3 class="con_top"><a href="<?php
echo hg_build_link("upload.php");
?>
">+上传视频</a><a href="javascript:void(0);"onclick="create_album(1);">+创建专辑</a>我的专辑</h3>
<div class="show_info">
<div class="album">
<ul class="album_ul">
{if $album_info}
{foreach $album_info as $key => $value}
<li class="album_li" onmousemove="album_mouse({$value['id']},0)" onmouseout="album_mouse({$value['id']},1)">
<a href="javascript:void(0);" onclick="manage_album_video({$value['id']});"><img src="{$value['cover']}"/></a>
<div id="album_na_{$value['id']}" class="album_na">
<a href="javascript:void(0);" onclick="manage_album_video({$value['id']});"><?php
echo hg_cutchars($value['name'], 8, " ");
?>
({$value['video_count']})</a>
</div>
<div id="album_ma_{$value['id']}" class="album_ma" style="display:none;">
<!-- <a target="_blank" href="<?php
echo hg_build_link('user_album_video.php', array('id' => $value['id'], 'user_id' => $value['user_id']));
?>
">预览</a>-->
<a href="javascript:void(0);" onclick="del_album({$value['id']});">删除</a>
<a href="javascript:void(0);" onclick="edit_album_info({$value['id']});">编辑</a>
</div>
</li>
{/foreach}
{else}
<li>
示例9: hg_build_link
{foreach $station_info as $key => $value}
<li class="search_li">
<ul class="search_result">
<li><a target="_blank" href="<?php
echo hg_build_link(SNS_VIDEO . "station_play.php", array("sta_id" => $value['id']));
?>
"><img src="{$value['small']}"/></a></li>
<li>名称:<a target="_blank" href="<?php
echo hg_build_link(SNS_VIDEO . "station_play.php", array("sta_id" => $value['id']));
?>
"><?php
echo hg_match_red(hg_cutchars($value['web_station_name'], 7, " "), $name);
?>
</a></li>
<li>标签:<?php
echo $value['tags'] ? hg_tags(hg_cutchars($value['tags'], 7, " "), $name, "station_search.php") : "暂无";
?>
</li>
<li>点击次数:{$value['click_count']}</li>
</ul>
</li>
{/foreach}
</ul>
{$showpages}
{/if}
</div>
<div class="con_bottom clear"></div>
{/if}
</div>
</div>
{template:unit/my_right_menu}
示例10: getProduct
public function getProduct($page)
{
//获取接口数据
$data = $this->getXcpw($page);
//hg_pre($data);exit();
if ($data['dtsource']) {
$count = $data['recordcount'] ? $data['recordcount'] : 0;
$totalpage = $data['totalpages'] ? $data['totalpages'] : 0;
$perpage = $data['totalperpage'] ? $data['totalperpage'] : 0;
//获取抓取纪录
$sql = 'SELECT * FROM ' . DB_PREFIX . 'xcpw_show';
$query = $this->db->query($sql);
$record = array();
while ($row = $this->db->fetch_array($query)) {
$record[$row['xc_id']] = $row['show_id'];
}
//获取索引图纪录
$sql = 'SELECT s.id as sid,s.index_id,s.status,m.* FROM ' . DB_PREFIX . 'show s
LEFT JOIN ' . DB_PREFIX . 'material m ON s.index_id = m.id';
$query = $this->db->query($sql);
$m_record = array();
while ($row = $this->db->fetch_array($query)) {
$m_record[$row['sid']] = $row['id'];
$st[$row['sid']] = $row['status'];
}
//hg_pre($m_record);exit();
$num = 0;
$number = $count - ($page - 1) * $perpage;
if ($number >= $perpage) {
$num = $perpage;
} else {
$num = $number;
}
if ($num > 0) {
for ($i = 0; $i < $num; $i++) {
$insert_id = '';
$material_id = '';
$price_ids = '';
$low_price = 0;
$show_id = '';
$temp = $data['dtsource'][$num - ($i + 1)];
if ($temp && is_array($temp) && !empty($temp)) {
if (in_array($temp['id'], array_keys($record))) {
$show_id = $record[$temp['id']];
}
if (!$show_id || $show_id && $st[$show_id] == 0) {
$state = '';
switch ($temp['state']) {
case 0:
$state = 0;
break;
case 1:
$state = 1;
break;
case 2:
$state = 2;
break;
case 3:
$state = 3;
break;
case 10:
$state = 10;
break;
}
//商品信息处理
$arr = array('id' => $show_id, 'title' => $temp['name'], 'brief' => $temp['brief'], 'venue' => $temp['host'], 'address' => $temp['address'], 'show_time' => $temp['time_notes'], 'start_time' => strtotime($temp['start_time_str']), 'end_time' => strtotime($temp['end_time_str']), 'price_notes' => addslashes($temp['price_notes']), 'goods_total' => intval($temp['goods_total']), 'goods_total_left' => intval($temp['goods_total_left']), 'sale_state' => $state, 'appid' => $this->user['appid'], 'client' => $this->user['display_name'], 'create_time' => TIMENOW, 'update_time' => TIMENOW, 'user_id' => $temp['create_userid'], 'user_name' => $temp['create_username']);
if (!$arr['brief'] && $temp['notes']) {
$arr['brief'] = hg_cutchars(strip_tags($temp['notes']), 100);
}
$sql = 'REPLACE INTO ' . DB_PREFIX . 'show SET ';
foreach ($arr as $kk => $vv) {
$sql .= $kk . '="' . addslashes($vv) . '",';
}
$sql = rtrim($sql, ',');
$this->db->query($sql);
$insert_id = $this->db->insert_id();
//索引图处理
if ($temp['logo']['original']) {
$url = 'http://' . $this->settings['App_xcpw']['host'] . '/' . $temp['logo']['original'];
$res = $this->material->localMaterial($url, $insert_id);
//入素材库
if (!empty($res)) {
$res = $res[0];
$materials = array('show_id' => $res['cid'], 'index_url' => serialize(array('host' => $res['host'], 'dir' => $res['dir'], 'filepath' => $res['filepath'], 'filename' => $res['filename'])), 'type' => $res['type'], 'original_id' => $res['id'], 'create_time' => TIMENOW, 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name']);
if (!in_array($show_id, array_keys($m_record))) {
$sql = 'INSERT INTO ' . DB_PREFIX . 'material SET ';
foreach ($materials as $key => $val) {
$sql .= $key . '="' . addslashes($val) . '",';
}
$sql = rtrim($sql, ',');
$this->db->query($sql);
$material_id = $this->db->insert_id();
} else {
$sql = 'UPDATE ' . DB_PREFIX . 'material SET ';
foreach ($materials as $key => $val) {
$sql .= $key . '="' . addslashes($val) . '",';
}
$sql = rtrim($sql, ',');
$sql .= ' WHERE show_id = ' . $show_id;
$this->db->query($sql);
//.........这里部分代码省略.........
示例11: create
public function create()
{
$content = addslashes(trim($this->input['content']));
if (!$content) {
$this->errorOutput('请输入报料内容');
}
$data = array('title' => addslashes(trim($this->input['title'])), 'brief' => addslashes(trim($this->input['brief'])), 'appid' => $this->user['appid'], 'client' => $this->user['display_name'], 'audit' => 1, 'sort_id' => intval($this->input['sort_id']), 'org_id' => $this->user['org_id'], 'is_m2o' => 1, 'user_id' => $this->input['user_name'] ? 0 : $this->user['user_id'], 'user_name' => $this->input['user_name'] ? addslashes($this->input['user_name']) : addslashes($this->user['user_name']), 'create_time' => TIMENOW, 'ip' => $this->user['ip'], 'baidu_longitude' => trim($this->input['baidu_longitude']), 'baidu_latitude' => trim($this->input['baidu_latitude']), 'event_time' => strtotime($this->input['event_time']), 'event_address' => trim($this->input['event_address']), 'event_suggest' => trim($this->input['event_suggest']), 'event_user_name' => trim($this->input['event_user_name']), 'event_user_tel' => trim($this->input['event_user_tel']), 'is_follow' => intval($this->input['is_follow']));
if (!$data['sort_id']) {
$data['sort_id'] = 0;
}
if (!$data['title']) {
$data['title'] = hg_cutchars($content, 20);
}
if (!$data['brief']) {
$data['brief'] = hg_cutchars($content, 100);
}
//如果百度坐标存在的话,就转换为GPS坐标也存起来
if ($data['baidu_longitude'] && $data['baidu_latitude']) {
$gps = $this->contribute->FromBaiduToGpsXY($data['baidu_longitude'], $data['baidu_latitude']);
$data['GPS_longitude'] = $gps['GPS_x'];
$data['GPS_latitude'] = $gps['GPS_y'];
}
/**************权限控制开始**************/
//节点权限
if ($data['sort_id'] && $this->user['group_type'] > MAX_ADMIN_TYPE) {
$sql = 'SELECT id, parents FROM ' . DB_PREFIX . 'sort WHERE id = ' . $data['sort_id'];
$sort = $this->db->query_first($sql);
$nodes['nodes'][$sort['id']] = $sort['parents'];
}
$nodes['_action'] = 'manage';
$this->verify_content_prms($nodes);
//创建数据后的审核状态
if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
if ($this->user['prms']['default_setting']['create_content_status'] == 1) {
$data['audit'] = 1;
} elseif ($this->user['prms']['default_setting']['create_content_status'] == 2) {
$data['audit'] = 2;
}
}
/**************权限控制结束**************/
//添加爆料主表
$contributeId = $this->contribute->add_content($data);
if (!intval($contributeId)) {
$this->errorOutput('数据库插入失败');
}
//添加内容表
$body = array('id' => $contributeId, 'text' => $content);
$this->contribute->add_contentbody($body);
$userinfo = array();
//用户信息
$userinfo['con_id'] = intval($contributeId);
$userinfo['tel'] = addslashes($this->input['tel']);
$userinfo['email'] = addslashes($this->input['email']);
$userinfo['addr'] = addslashes($this->input['addr']);
if (!empty($userinfo)) {
$this->contribute->user_info($userinfo);
}
//视频上传
if ($_FILES['videofile']) {
$video = array();
//检测视频服务器
if (!$this->settings['App_mediaserver']) {
$this->errorOutput('视频服务器未安装!');
}
//获取视频服务器上传配置
$videoConfig = $this->contribute->getVideoConfig();
if (!$videoConfig) {
$this->errorOutput('获取允许上传的视频类型失败!');
}
$count = count($_FILES['videofile']['name']);
for ($i = 0; $i <= $count; $i++) {
if ($_FILES['videofile']['name'][$i]) {
if ($_FILES['videofile']['error'][$i] > 0) {
$this->errorOutput('视频异常');
}
$filetype = '';
$filetype = strtolower(strrchr($_FILES['videofile']['name'][$i], '.'));
if (!in_array($filetype, $videoConfig['type'])) {
$this->errorOutput('只允许上传' . $videoConfig['hit'] . '格式的视频');
}
foreach ($_FILES['videofile'] as $k => $v) {
$video['videofile'][$k] = $_FILES['videofile'][$k][$i];
}
$videos[] = $video;
}
}
if (!empty($videos)) {
//循环上传视频
foreach ($videos as $val) {
$videodata = '';
//上传视频服务器
$videodata = $this->contribute->uploadToVideoServer($val, $data['title'], $data['brief']);
if (!$videodata) {
$this->errorOutput('视频服务器错误!');
}
$info[] = $videodata;
//有视频没有图片时,将视频截图上传作为索引图
if (!$indexpic) {
$url = $videodata['img']['host'] . $videodata['img']['dir'] . $videodata['img']['filepath'] . $videodata['img']['filename'];
$material = $this->contribute->localMaterial($url, $contributeId);
//.........这里部分代码省略.........
示例12: create
/**
* 增加投稿
*/
function create()
{
//添加爆料主表
$data = array('title' => trim(urldecode($this->input['title'])), 'brief' => addslashes(trim(urldecode($this->input['brief']))), 'appid' => $this->user['appid'], 'client' => $this->user['display_name'], 'longitude' => trim(urldecode($this->input['longitude'])), 'latitude' => trim(urldecode($this->input['latitude'])), 'create_time' => TIMENOW, 'user_id' => $this->input['user_name'] ? 0 : $this->user['user_id'], 'user_name' => addslashes($this->input['user_name']) ? addslashes($this->input['user_name']) : addslashes($this->user['user_name']), 'audit' => 1, 'sort_id' => trim(urldecode($this->input['sort_id'])), 'org_id' => $this->user['org_id']);
$content = addslashes(trim(urldecode($this->input['content'])));
if (!$content) {
$this->errorOutput('请输入投稿内容');
}
/**************权限控制开始**************/
//节点权限
if ($data['sort_id']) {
$sql = 'SELECT id, parents FROM ' . DB_PREFIX . 'sort WHERE id = ' . $data['sort_id'];
$sort = $this->db->query_first($sql);
$nodes['nodes']['reporter_node'][$sort['id']] = $sort['parents'];
} else {
$nodes['nodes']['reporter_node'] = array(0 => 0);
}
$this->verify_content_prms($nodes);
//创建数据后的审核状态
if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
if ($this->user['prms']['default_setting']['create_content_status'] == 1) {
$data['audit'] = 1;
} elseif ($this->user['prms']['default_setting']['create_content_status'] == 2) {
$data['audit'] = 2;
}
}
/**************权限控制结束**************/
if (!$data['sort_id']) {
$data['sort_id'] = 0;
} else {
//获取该分类下的发布栏目
$sortInfor = $this->con->getSortInfor($data['sort_id']);
if (!empty($sortInfor)) {
$data['column_id'] = addslashes($sortInfor[$data['sort_id']]['column_id']);
}
}
if (!$data['title']) {
$data['title'] = hg_cutchars($content, 20);
}
if (!$data['brief']) {
$data['brief'] = hg_cutchars($content, 100);
}
$contribute_id = $this->con->add_content($data);
/****************添加日志*****************/
if ($contribute_id) {
$sql = 'SELECT * FROM ' . DB_PREFIX . 'content WHERE id = ' . $contribute_id;
$ret = $this->db->query_first($sql);
$this->addLogs('添加报料', '', $ret);
}
/****************添加日志****************/
//添加内容表
$body = array('id' => $contribute_id, 'text' => $content);
$this->con->add_contentbody($body);
$userinfo = array();
//用户信息
if ($this->input['user_name']) {
$userinfo = array('con_id' => intval($contribute_id), 'tel' => $this->input['tel'], 'email' => addslashes($this->input['email']), 'addr' => addslashes($this->input['addr']));
} elseif ($this->user['user_id'] && !$this->input['user_name']) {
$return = $this->con->get_userinfo_by_id($this->user['user_id']);
if (!empty($return)) {
$userinfo = array('con_id' => intval($contribute_id), 'tel' => $return['mobile'], 'email' => $return['email'], 'addr' => $return['address']);
}
}
if (!empty($userinfo)) {
$this->con->user_info($userinfo);
}
//图片上传
if ($_FILES['photos']) {
$count = count($_FILES['photos']['error']);
for ($i = 0; $i <= $count; $i++) {
if ($_FILES['photos']['error'][$i] === 0) {
$pics = array();
foreach ($_FILES['photos'] as $k => $v) {
$pics['Filedata'][$k] = $_FILES['photos'][$k][$i];
}
//插入图片服务器
$ret = $this->con->uploadToPicServer($pics, $contribute_id);
//准备入库数据
$arr = array('content_id' => $contribute_id, 'mtype' => $ret['type'], 'original_id' => $ret['id'], 'host' => $ret['host'], 'dir' => $ret['dir'], 'material_path' => $ret['filepath'], 'pic_name' => $ret['filename']);
$id = $this->con->upload($arr);
//默认第一张图片为索引图
if (!$indexpic) {
$indexpic = $this->con->update_indexpic($id, $contribute_id);
}
}
}
}
//视频上传
if ($_FILES['videofile']) {
//上传视频服务器
$videodata = $this->con->uploadToVideoServer($_FILES, $data['title'], $data['brief']);
//有视频没有图片时,将视频截图上传作为索引图
if (!$indexpic) {
$url = $videodata['img']['host'] . $videodata['img']['dir'] . $videodata['img']['filepath'] . $videodata['img']['filename'];
$material = $this->con->localMaterial($url, $contribute_id);
$arr = array('content_id' => $contribute_id, 'mtype' => $material['type'], 'original_id' => $material['id'], 'host' => $material['host'], 'dir' => $material['dir'], 'material_path' => $material['filepath'], 'pic_name' => $material['filename']);
$indexpic = $this->con->upload($arr);
//.........这里部分代码省略.........
示例13: accept
if (!$config) {
return false;
}
$this->autoReply = $config['auto_reply'];
$this->replyCon = $config['reply_content'];
$this->token = $config['token'];
}
/**
* 接受用户发送的微信消息
*/
public function accept()
{
if (isset($_GET["echostr"])) {
$checkResult = $this->checkSignature();
if ($checkResult) {
echo $_GET["echostr"];
exit;
}
}
//获取POST数据
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
//处理POST数据
if (!empty($postStr)) {
//解析收到的数据
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$fromUserName = trim($postObj->FromUserName);
$toUserName = trim($postObj->ToUserName);
$createTime = intval($postObj->CreateTime);
$msgType = trim($postObj->MsgType);
$msgId = intval($postObj->MsgId);
$text = isset($postObj->Content) ? trim($postObj->Content) : '';
$picUrl = isset($postObj->PicUrl) ? trim($postObj->PicUrl) : '';
$latitude = isset($postObj->Location_X) ? floatval($postObj->Location_X) : -1;
$longitude = isset($postObj->Location_Y) ? floatval($postObj->Location_Y) : -1;
$scale = isset($postObj->Scale) ? intval($postObj->Scale) : -1;
$location = isset($postObj->Label) ? trim($postObj->Label) : '';
$title = isset($postObj->Title) ? trim($postObj->Title) : '';
$description = isset($postObj->Description) ? trim($postObj->Description) : '';
$url = isset($postObj->Url) ? trim($postObj->Url) : '';
$data = array('fromUserName' => $fromUserName, 'toUserName' => $toUserName, 'createTime' => $createTime, 'msgType' => $msgType, 'msgId' => $msgId);
if (!empty($text)) {
$data['brief'] = hg_cutchars($text, 100);
}
if (!empty($picUrl)) {
$data['picUrl'] = $picUrl;
}
if ($latitude != -1) {
$data['latitude'] = $latitude;
}
if ($longitude != -1) {
$data['longitude'] = $longitude;
}
if ($scale != -1) {
$data['scale'] = $scale;
}
if (!empty($location)) {
$data['location'] = $location;
}
if (!empty($title)) {
$data['title'] = $title;
}
if (!empty($description)) {
$data['description'] = $description;
}
if (!empty($url)) {
$data['url'] = $url;
}
$info = $this->weixin->create('message', $data);
if ($data['msgType'] == 'text') {
$textData = array('id' => $info['id'], 'content' => $text);
$this->weixin->create('text_data', $textData);
}
//设置自动回复信息
if ($this->autoReply) {
//默认回复文本信息
$fromUsername = $data['fromUserName'];
$toUsername = $data['toUserName'];
示例14: show
/**
*
* 获取文章详细内容
*/
public function show()
{
$id = $this->input['id'] ? intval($this->input['id']) : -1;
if ($pubdate = trim(urldecode($this->input['pre']))) {
//以日期为标准 前一篇文章
$condition = 'cm.pubdate < ' . $pubdate;
} else {
if ($pubdate = trim(urldecode($this->input['next']))) {
//以日期为标准 后一篇文章
$condition = 'cm.pubdate > ' . $pubdate;
} else {
$condition = '';
}
}
//符合html标记 不全
$allow_tags = array('<a>', '<p>', '<br>');
$liv_proc = array('android' => 'httplive://');
$img_event = array(1 => 'showImg', 2 => 'livAndroid.showImg');
if ($id > 0 || $condition != '') {
//有ID则以ID查询覆盖时间条件 否则已时间条件查询文章详细信息
if ($id > 0) {
$condition = 'cm.id = ' . $id;
}
$sql = "SELECT cm.id,cm.pubdate,cm.modeid, cm.columnid,cm.contentid,mat.materialid,mat.filepath,mat.filename, mat.thumbfile, col.columnid,col.colname\r\n\t\t\t\tFROM " . DB_PREFIX . "contentmap cm \r\n\t\t\t\t\tleft join " . DB_PREFIX . "material mat \r\n\t\t\t\t\t\ton mat.materialid = cm.indexpic \r\n\t\t\t\t\tleft join " . DB_PREFIX . "column col\r\n\t\t\t\t\t\ton cm.columnid=col.columnid\r\n\t\t\t\t\tWHERE {$condition} \r\n\t\t\t\t\t\tand cm.status=3\r\n\t\t\t\t\t\tand cm.siteid=" . $this->site['siteid'];
if ($this->input['debug']) {
echo $sql;
}
//exit($sql);
$r = $this->db->query_first($sql);
if (!$r) {
$this->errorOutput('内容不存在或已被删除');
}
$msql = 'SELECT ma.*, c.modesign FROM ' . DB_PREFIX . 'mode_apply ma LEFT JOIN ' . DB_PREFIX . 'contentmode c ON ma.colmodeid=c.colmodeid WHERE ma.applyid=' . $r['modeid'];
$mode = $this->db->query_first($msql);
if ($r) {
$csql = 'SELECT COUNT(*) AS count FROM ' . DB_PREFIX . 'comment WHERE contentid=' . $id;
$c = $this->db->query_first($csql);
}
$r['indexpic'] = $this->getimageurl($r, 'filename');
$r['picurl'] = $r['indexpic'];
$modec = $this->db->query_first('SELECT * FROM ' . DB_PREFIX . $mode['modesign'] . ' WHERE ' . $mode['modesign'] . 'id=' . $r['contentid']);
$r = $r + $modec;
if ($modec['subtitle']) {
$r['brief'] = hg_cutchars($modec['subtitle'], 30, '');
}
if (!$r['videoid']) {
$r['videoid'] = $r['vid'];
}
if ($r['videoid']) {
include_once ROOT_PATH . 'lib/class/curl.class.php';
$curl = new curl($this->settings['App_livmedia']['host'], $this->settings['App_livmedia']['dir']);
$curl->initPostData();
$curl->addRequestData('a', 'detail');
$curl->addRequestData('id', $r['videoid']);
$video_info = $curl->request('vod.php');
$video_info = $video_info[0];
if ($video_info) {
$curl->addRequestData('a', 'updateclick');
$curl->request('vod.php');
$r['video'] = array('host' => rtrim($video_info['hostwork'], '/') . '/', 'dir' => '', 'filepath' => $video_info['video_path'], 'filename' => str_replace('.mp4', '.m3u8', $video_info['video_filename']), 'is_audio' => $video_info['is_audio']);
$r['vodurl'] = $video_info['vodurl'];
$r['vodid'] = $video_info['vodid'];
}
$r['newcontent'] = $modec['comment'];
} else {
$r['vodurl'] = '';
$r['vodid'] = 0;
}
//内容转存于body表中 取出并拼接
$weburl = $this->site['weburl'];
if ($mode['bodyfield']) {
$content = $this->getAllContent($r['articleid'], $r['modeid']);
@eval('$content = "' . addslashes($content) . ' " ;');
$r['newcontent'] = $content;
}
$r['pubdate'] = date('Y-m-d H:i:s', $r['pubdate']);
$r['comment_count'] = intval($c['count']);
$pics = array();
if ($r['newcontent']) {
//获取内容中存在的所有图片
preg_match_all("/<img\\s+.*?\\s*src\\s*=\\s*[\\'\"]([^\\'\">\\s]*)[\\'\"]\\s*[^>]*>/is", $r['newcontent'], $imgs);
if ($imgs[1]) {
$i = 0;
foreach ($imgs[1] as $v) {
//$hg_pics[] = '<div class="img" onclick="' . $img_event[$this->input['source']] . '(\'' . $v . '\');" ><img src="' . $v . '" width="70" /><span class="img_show"></span></div>';
$v = explode('liv_loadfile/', $v);
if (defined('CMS_IMG_DOMAIN') && CMS_IMG_DOMAIN && $v[0] == $this->site['weburl'] && $v[1]) {
$pic = array('host' => CMS_IMG_DOMAIN, 'dir' => '', 'filepath' => '', 'filename' => $v[1]);
$pics[$i]['pic'] = $pic;
$i++;
} else {
if (!$v[1]) {
$v[1] = '';
$idir = '';
} else {
$idir = 'liv_loadfile/';
//.........这里部分代码省略.........
示例15: hg_build_link
?>
" ><img title="<?php
echo $v['username'];
?>
" style="border: 1px solid silver; height: 50px;padding: 2px;width: 50px;" src="<?php
echo $v['middle_avatar'];
?>
" /></a>
<a title="<?php
echo $v['username'];
?>
" href="<?php
echo hg_build_link(SNS_UCENTER . 'user.php', array('user_id' => $v['id']));
?>
"><?php
echo hg_cutchars($v['username'], 3, '...', 1);
?>
</a>
<div class="close-concern">
<?php
if ($this->user['id'] == $v['id']) {
} else {
if ($v['is_friend'] == 1) {
?>
<p><span class="been-concern">√已关注</span> </p>
<?php
} else {
?>
<p id="<?php
echo 'add_' . $v['id'];