本文整理汇总了PHP中parse_html函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_html函数的具体用法?PHP parse_html怎么用?PHP parse_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_html函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCommentList
/**
* 获取评论列表,已在后台被使用
* @param array $map 查询条件
* @param string $order 排序条件,默认为comment_id ASC
* @param integer $limit 结果集数目,默认为10
* @param boolean $isReply 是否显示回复信息
* @return array 评论列表信息
*/
public function getCommentList($map = null, $order = 'comment_id ASC', $limit = 10, $isReply = false)
{
!$map['app'] && $this->_app && ($map['app'] = $this->_app);
!$map['table'] && $this->_app_table && ($map['table'] = $this->_app_table);
!isset($map['is_del']) && ($map['is_del'] = 0);
$data = $this->where($map)->order($order)->findPage($limit);
// dump($data);exit;
// TODO:后续优化
foreach ($data['data'] as &$v) {
if (!empty($v['to_comment_id']) && $isReply) {
$replyInfo = $this->setAppName($map['app'])->setAppTable($map['table'])->getCommentInfo(intval($v['to_comment_id']), false);
$v['replyInfo'] = '//@{uid=' . $replyInfo['user_info']['uid'] . '|' . $replyInfo['user_info']['uname'] . '}:' . $replyInfo['content'];
}
$v['user_info'] = model('User')->getUserInfo($v['uid']);
$groupData = static_cache('groupdata' . $v['uid']);
if (!$groupData) {
$groupData = model('UserGroupLink')->getUserGroupData($v['uid']);
if (!$groupData) {
$groupData = 1;
}
static_cache('groupdata' . $v['uid'], $groupData);
}
$v['user_info']['groupData'] = $groupData;
//获取用户组信息
$v['content'] = parse_html($v['content'] . $v['replyInfo']);
$v['sourceInfo'] = model('Source')->getSourceInfo($v['table'], $v['row_id'], false, $v['app']);
//$v['data'] = unserialize($v['data']);
}
return $data;
}
示例2: notify
/**
* 系统通知
* @return void
*/
public function notify()
{
//$list = model('Notify')->getMessageList($this->mid); //2012/12/27
//下边这句是为了获取$count
$limit = 20;
$list = D('notify_message')->where('uid=' . $this->mid)->order('ctime desc')->findpage($limit);
$count = $list['count'];
$this->assign('count', $count);
$page = $_GET['page'] ? intval($_GET['page']) : 1;
$start = ($page - 1) * $limit;
$list = D('notify_message')->where('uid=' . $this->mid)->order('ctime desc')->limit("{$start},{$limit}")->select();
foreach ($list as $k => $v) {
$list[$k]['body'] = parse_html($v['body']);
if ($appname != 'public') {
$list[$k]['app'] = model('App')->getAppByName($v['appname']);
}
}
model('Notify')->setRead($this->mid);
$this->assign('page', $page);
$this->assign('list', $list);
$this->setTitle(L('PUBLIC_MESSAGE_NOTIFY'));
$this->setKeywords(L('PUBLIC_MESSAGE_NOTIFY'));
$this->assign('headtitle', '系统通知');
$this->display('mynotify');
}
示例3: parse_response
function parse_response($api, $params)
{
global $records;
$page = $params['from'] / $params['size'] + 1;
echo "Page {$page}\n";
//compare the individual request parameters into k=>v pairs to the URL
$qparams = array();
foreach ($params as $k => $v) {
$qparams[] = "{$k}=" . urlencode($v);
}
$service = $api . implode('&', $qparams);
//request JSON from API
$json = file_get_contents($service);
$data = json_decode($json);
//iterate through results
foreach ($data->results as $result) {
$record = array();
$record['id'] = $result->priref;
$record['uri'] = "http://data.fitzmuseum.cam.ac.uk/id/object/{$result->priref}";
$record['objectnumber'] = $result->ObjectNumber;
$record['title'] = "Fitzwilliam Museum - Object {$result->ObjectNumber}";
$imageCount = 0;
foreach ($result->images->thumbnailURI as $url) {
switch ($imageCount) {
case 0:
$record['obv_image'] = $url;
break;
case 1:
$record['rev_image'] = $url;
}
$imageCount++;
}
//begin screen scraping
$url = "http://webapps.fitzmuseum.cam.ac.uk/explorer/index.php?oid={$result->priref}";
$fields = parse_html($url);
if (isset($fields['reference'])) {
$record['reference'] = $fields['reference'];
}
if (isset($fields['coinType'])) {
$record['cointype'] = $fields['coinType'];
}
if (isset($fields['weight'])) {
$record['weight'] = $fields['weight'];
}
if (isset($fields['axis'])) {
$record['axis'] = $fields['axis'];
}
$records[] = $record;
}
//var_dump($records);
//if there are more pages to parse, curse function
$numFound = $data->total;
if ($params['from'] + $params['size'] <= $numFound) {
$params['from'] = $params['from'] + $params['size'];
parse_response($api, $params);
}
}
示例4: getReplyList
/**
* 获取回复列表
* @param array $map 查询条件
* @param string $order 排序条件,默认为comment_id ASC
* @param integer $limit 结果集数目,默认为10
* @return array 评论列表信息
*/
public function getReplyList($map = null, $order = 'reply_id desc', $limit = 10)
{
!isset($map['is_del']) && ($map['is_del'] = 0);
$data = $this->where($map)->order($order)->findPage($limit);
// // TODO:后续优化
foreach ($data['data'] as &$v) {
$v['user_info'] = model('User')->getUserInfo($v['uid']);
$v['user_info']['groupData'] = model('UserGroupLink')->getUserGroupData($v['uid']);
//获取用户组信息
$v['content'] = parse_html(h(htmlspecialchars($v['content'])));
//$v['sourceInfo'] = model('Source')->getSourceInfo($v['table'], $v['row_id'], false, $v['app']);
}
return $data;
}
示例5: tz
public function tz()
{
$map['uid'] = $this->mid;
$list = D('notify_message')->where($map)->order('ctime desc')->findpage(20);
foreach ($list['data'] as $k => $v) {
$list['data'][$k]['body'] = parse_html($v['body']);
if ($v['appname'] != 'public') {
$list['data'][$k]['app'] = model('App')->getAppByName($v['appname']);
}
}
model('Notify')->setRead($this->mid);
$this->assign('list', $list);
$this->display();
}
示例6: notify
/**
* 系统通知
* @return void
*/
public function notify()
{
//$list = model('Notify')->getMessageList($this->mid); //2012/12/27
$list = D('notify_message')->where('uid=' . $this->mid)->order('ctime desc')->findpage(20);
foreach ($list['data'] as $k => $v) {
$list['data'][$k]['body'] = parse_html($v['body']);
if ($appname != 'public') {
$list['data'][$k]['app'] = model('App')->getAppByName($v['appname']);
}
}
model('Notify')->setRead($this->mid);
$this->assign('list', $list);
// dump($list);
$this->setTitle(L('PUBLIC_MESSAGE_NOTIFY'));
$this->setKeywords(L('PUBLIC_MESSAGE_NOTIFY'));
$this->display('mynotify');
}
示例7: getReplyList
/**
* 获取回复列表
* @param array $map 查询条件
* @param string $order 排序条件,默认为comment_id ASC
* @param int $limit 结果集数目,默认为10
* @return array 评论列表信息
*/
public function getReplyList($map = null, $order = 'reply_id desc', $limit = 10)
{
!isset($map['is_del']) && ($map['is_del'] = 0);
$data = $this->where($map)->order($order)->findPage($limit);
// // TODO:后续优化
foreach ($data['data'] as &$v) {
$v['user_info'] = model('User')->getUserInfo($v['uid']);
$v['user_info']['groupData'] = model('UserGroupLink')->getUserGroupData($v['uid']);
//获取用户组信息
$v['content'] = parse_html(h(htmlspecialchars($v['content'])));
//$v['sourceInfo'] = model('Source')->getSourceInfo($v['table'], $v['row_id'], false, $v['app']);
$v['attach_info'] = model('Attach')->getAttachById($v['attach_id']);
if ($v['attach_info']['attach_type'] == 'weiba_comment_image' || $v['attach_info']['attach_type'] == 'feed_image') {
$v['attach_info']['attach_url'] = getImageUrl($v['attach_info']['save_path'] . $v['attach_info']['save_name'], 590);
}
}
return $data;
}
示例8: get_data
function get_data($num, $url)
{
$str = file_get_contents($url);
$str = trim($str);
$str = strtolower($str);
if ($str == '') {
$str = file_get_contents($url);
}
if ($str == '') {
// recode error
$fp = fopen('cantdown_' . $num, 'a+');
fputs($fp, $num . '\\r\\n');
fclose($fp);
} else {
$data = parse_html($str);
if (insert_db($num, $data)) {
echo $num . "is ok \r\n";
}
}
}
示例9: edit
public function edit($_id = '')
{
$this->assigns_layout["gnb_left"] = "contents";
if ($_REQUEST["subject"]) {
$content_parsed = parse_html($_REQUEST["contents"]);
foreach ($content_parsed as $c) {
if (strtolower(substr($c, 0, 4)) == "<img") {
$t = tag_barase($c);
if ($t["src"]) {
$_REQUEST["img"] = $t["src"];
break;
}
}
}
$_id = $this->Content->add($_REQUEST);
if ($_REQUEST["pic"]) {
$img_temp_name = str_replace(" ", "", $_REQUEST['pic']);
$ck = substr($img_temp_name, 0, 1);
if ($ck == '/') {
$img_temp_name = substr($img_temp_name, 1, strlen($img_temp_name) - 1);
}
$file_ext = explode('.', $img_temp_name);
//$filename = basename($_FILES['file']['name']);
$file_ext = '.' . $file_ext[sizeof($file_ext) - 1];
$original_file = $this->settings->root_path . $img_temp_name;
$copy_file = $this->settings->root_path . 'media/contents/' . $_id . $file_ext;
GD2_make_thumb_x(300, "", $original_file);
//그림 파일 update 폴더로 옮긴 후 임시파일 삭제
copy($original_file, $copy_file);
unlink($original_file);
$_pic = '/media/contents/' . $_id . $file_ext;
$this->Content->add_picture($_id, $_pic);
}
header("Location: /admin_contents");
}
if ($_id) {
$this->assigns["res"] = $this->Content->get($_id);
}
$this->assigns["cat"] = $this->Content_category->list_(1, 100);
}
示例10: reply_commentList
/**
* [ 获取评论的评论列表]
* @return [type] [description]
*/
public function reply_commentList()
{
if (!CheckPermission('weiba_normal', 'weiba_reply')) {
return false;
}
$var = $_POST;
$var['initNums'] = model('Xdata')->getConfig('weibo_nums', 'feed');
$var['commentInfo'] = model('Comment')->getCommentInfo($var['comment_id'], false);
$var['canrepost'] = $var['commentInfo']['table'] == 'feed' ? 1 : 0;
$var['cancomment'] = 1;
// 获取原作者信息
$rowData = model('Feed')->get(intval($var['commentInfo']['row_id']));
$appRowData = model('Feed')->get($rowData['app_row_id']);
$var['user_info'] = $appRowData['user_info'];
// 微博类型
$var['feedtype'] = $rowData['type'];
// $var['cancomment_old'] = ($var['commentInfo']['uid'] != $var['commentInfo']['app_uid'] && $var['commentInfo']['app_uid'] != $this->uid) ? 1 : 0;
if ($var['flag'] != 1) {
$var['initHtml'] = L('PUBLIC_STREAM_REPLY') . '@' . $var['commentInfo']['user_info']['uname'] . ' :';
}
//获取回评
$commentList = D('weiba_reply')->where('is_del = 0 and to_reply_id=' . $var['to_reply_id'])->order('ctime')->select();
foreach ($commentList as $k => $v) {
$commentList[$k]['content'] = parse_html(h(htmlspecialchars($v['content'])));
}
$this->assign('commentList', $commentList);
$uids = getSubByKey($commentList, 'uid');
$this->_assignUserInfo($uids);
$this->assign('reply_id', $var['to_reply_id']);
$this->assign('var', $var);
if ($var[type] == 2) {
$con = $this->fetch('reply_commentList1');
} else {
$con = $this->fetch();
}
echo $con;
}
示例11: addComment
/**
* 添加评论操作
* @param array $data 评论数据
* @param boolean $forApi 是否用于API,默认为false
* @param boolean $notCount 是否统计到未读评论
* @param array $lessUids 除去@用户ID
* @return boolean 是否添加评论成功
*/
public function addComment($data, $forApi = false, $notCount = false, $lessUids = null)
{
// 判断用户是否登录
if (!$GLOBALS['ts']['mid']) {
$this->error = L('PUBLIC_REGISTER_REQUIRED');
// 请先登录
return false;
}
if (isSubmitLocked()) {
$this->error = '发布内容过于频繁,请稍后再试!';
return false;
}
/* # 将Emoji编码 */
$data['content'] = formatEmoji(true, $data['content']);
// 检测数据安全性
$add = $this->_escapeData($data);
if ($add['content'] === '') {
$this->error = L('PUBLIC_COMMENT_CONTENT_REQUIRED');
// 评论内容不可为空
return false;
}
$add['is_del'] = 0;
//判断是否先审后发
$filterStatus = filter_words($add['content']);
$weiboSet = model('Xdata')->get('admin_Config:feed');
$weibo_premission = $weiboSet['weibo_premission'];
if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit') || $filterStatus['type'] == 2) {
$add['is_audit'] = 0;
} else {
$add['is_audit'] = 1;
}
$add['client_ip'] = get_client_ip();
$add['client_port'] = get_client_port();
if ($res = $this->add($add)) {
//锁定发布
lockSubmit();
//添加楼层信息 弃用 20130607
/* $storeyCount = $this->where("table='".$add['table']."' and row_id=".$data['row_id'].' and comment_id<'.$res)->count();
$this->where('comment_id='.$res)->setField('storey',$storeyCount+1); */
if (!$add['is_audit']) {
$touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
$touidArr = getSubByKey($touid, 'uid');
model('Notify')->sendNotify($touidArr, 'comment_audit');
}
// 获取排除@用户ID
$lessUids[] = intval($data['app_uid']);
!empty($data['to_uid']) && ($lessUids[] = intval($data['to_uid']));
// 获取用户发送的内容,仅仅以//进行分割
$scream = explode('//', $data['content']);
model('Atme')->setAppName('Public')->setAppTable('comment')->addAtme(trim($scream[0]), $res, null, $lessUids);
// 被评论内容的“评论统计数”加1,同时可检测出app,table,row_id的有效性
$pk = D($add['table'])->getPk();
$where = "`{$pk}`={$add['row_id']}";
D($add['table'])->setInc('comment_count', $where);
//兼容旧版本app
// D($add['table'])->setInc('commentCount', $where);
// D($add['table'])->setInc('comment_all_count', $where);
D($add['app'])->setInc('commentCount', $where);
D($add['app'])->setInc('comment_all_count', $where);
//评论时间
M($add['app'])->where('feed_id=' . $add['row_id'])->setField('rTime', time());
// 给应用UID添加一个未读的评论数 原作者
if ($GLOBALS['ts']['mid'] != $add['app_uid'] && $add['app_uid'] != '' && $add['app_uid'] != $add['to_uid']) {
!$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['app_uid']);
}
// 回复发送提示信息
if (!empty($add['to_uid']) && $add['to_uid'] != $GLOBALS['ts']['mid']) {
!$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['to_uid']);
}
// 加积分操作
if ($add['table'] == 'feed') {
model('Credit')->setUserCredit($GLOBALS['ts']['mid'], 'comment_weibo');
model('Credit')->setUserCredit($data['app_uid'], 'commented_weibo');
model('Feed')->cleanCache($add['row_id']);
}
// 发邮件
if ($add['to_uid'] != $GLOBALS['ts']['mid'] || $add['app_uid'] != $GLOBALS['ts']['mid'] && $add['app_uid'] != '') {
$author = model('User')->getUserInfo($GLOBALS['ts']['mid']);
$config['name'] = $author['uname'];
$config['space_url'] = $author['space_url'];
$config['face'] = $author['avatar_small'];
$sourceInfo = model('Source')->getCommentSource($add, $forApi);
$config['content'] = parse_html($add['content']);
$config['ctime'] = date('Y-m-d H:i:s', time());
$config['sourceurl'] = $sourceInfo['source_url'];
$config['source_content'] = parse_html($sourceInfo['source_content']);
$config['source_ctime'] = isset($sourceInfo['ctime']) ? date('Y-m-d H:i:s', $sourceInfo['ctime']) : date('Y-m-d H:i:s');
if (!empty($add['to_uid'])) {
// 回复
$config['comment_type'] = '回复 我 的评论:';
model('Notify')->sendNotify($add['to_uid'], 'comment', $config);
} else {
//.........这里部分代码省略.........
示例12: addComment
/**
* 添加评论操作
* @param array $data 评论数据
* @param boolean $forApi 是否用于API,默认为false
* @param boolean $notCount 是否统计到未读评论
* @param array $lessUids 除去@用户ID
* @return boolean 是否添加评论成功
*/
public function addComment($data, $forApi = false, $notCount = false, $lessUids = null)
{
// 判断用户是否登录
if (!$GLOBALS['ts']['mid']) {
$this->error = L('PUBLIC_REGISTER_REQUIRED');
// 请先登录
return false;
}
// 设置评论绝对楼层
//$data['data']['storey'] = $this->getStorey($data['row_id'], $data['app'], $data['table']);
// 检测数据安全性
$add = $this->_escapeData($data);
if ($add['content'] === '') {
$this->error = L('PUBLIC_COMMENT_CONTENT_REQUIRED');
// 评论内容不可为空
return false;
}
$add['is_del'] = 0;
//判断是否先审后发
$weiboSet = model('Xdata')->get('admin_Config:feed');
$weibo_premission = $weiboSet['weibo_premission'];
if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit')) {
$add['is_audit'] = 0;
} else {
$add['is_audit'] = 1;
}
if ($res = $this->add($add)) {
//添加楼层信息
$storeyCount = $this->where('row_id=' . $data['row_id'] . ' and comment_id<' . $res)->count();
$this->where('comment_id=' . $res)->setField('storey', $storeyCount + 1);
if (!$add['is_audit']) {
$touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
foreach ($touid as $k => $v) {
model('Notify')->sendNotify($v['uid'], 'comment_audit');
}
}
// 获取排除@用户ID
$lessUids[] = intval($data['app_uid']);
!empty($data['to_uid']) && ($lessUids[] = intval($data['to_uid']));
// 获取用户发送的内容,仅仅以//进行分割
$scream = explode('//', $data['content']);
model('Atme')->setAppName('Public')->setAppTable('comment')->addAtme(trim($scream[0]), $res, null, $lessUids);
// 被评论内容的“评论统计数”加1,同时可检测出app,table,row_id的有效性
$pk = D($add['table'])->getPk();
D($add['table'])->setInc('comment_count', "`{$pk}`={$add['row_id']}", 1);
D($add['table'])->setInc('comment_all_count', "`{$pk}`={$add['row_id']}", 1);
// 给应用UID添加一个未读的评论数 原作者
if ($GLOBALS['ts']['mid'] != $add['app_uid'] && $add['app_uid'] != '') {
!$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['app_uid']);
}
// 回复发送提示信息
if (!empty($add['to_uid']) && $add['to_uid'] != $GLOBALS['ts']['mid']) {
!$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['to_uid']);
}
// 加积分操作
if ($add['table'] == 'feed') {
model('Credit')->setUserCredit($GLOBALS['ts']['mid'], 'comment_weibo');
model('Credit')->setUserCredit($data['app_uid'], 'commented_weibo');
model('Feed')->cleanCache($add['row_id']);
}
// 发邮件
if ($add['to_uid'] != $GLOBALS['ts']['mid'] || $add['app_uid'] != $GLOBALS['ts']['mid'] && $add['app_uid'] != '') {
$author = model('User')->getUserInfo($GLOBALS['ts']['mid']);
$config['name'] = $author['uname'];
$config['space_url'] = $author['space_url'];
$config['face'] = $author['avatar_middle'];
$sourceInfo = model('Source')->getSourceInfo($add['table'], $add['row_id'], $forApi, $add['app']);
$config['content'] = parse_html($add['content']);
$config['ctime'] = date('Y-m-d H:i:s', time());
$config['sourceurl'] = $sourceInfo['source_url'];
$config['source_content'] = parse_html($sourceInfo['source_content']);
$config['source_ctime'] = date('Y-m-d H:i:s', $sourceInfo['ctime']);
if (!empty($add['to_uid'])) {
// 回复
$config['comment_type'] = '回复 我 的评论:';
model('Notify')->sendNotify($add['to_uid'], 'comment', $config);
} else {
// 评论
$config['comment_type'] = '评论 我 的微博:';
if (!empty($add['app_uid'])) {
model('Notify')->sendNotify($add['app_uid'], 'comment', $config);
}
}
}
}
$this->error = $res ? L('PUBLIC_CONCENT_IS_OK') : L('PUBLIC_CONCENT_IS_ERROR');
// 评论成功,评论失败
return $res;
}
示例13: regular_express
function regular_express($regexp_array, $thevar)
{
#$regexp_array[2].='S'; # in benchmarks, this 'optimization' appeared to not do anything at all, or possibly even slow things down
if ($regexp_array[0] == 1) {
$newvar = preg_replace($regexp_array[2], $regexp_array[3], $thevar);
} elseif ($regexp_array[0] == 2) {
$addproxy = isset($regexp_array[4]) ? $regexp_array[4] : true;
$framify = isset($regexp_array[5]) ? $regexp_array[5] : false;
$newvar = parse_html($regexp_array[2], $regexp_array[3], $thevar, $addproxy, $framify);
}
return $newvar;
}
示例14: mysql_query
$sql = "select server, user, password, race, main_village, last_report from accounts where id = {$account}";
$res = mysql_query($sql);
if (!$res) {
die(mysql_error());
}
$row = mysql_fetch_row($res);
if (!$row) {
die("Account not found. {$account} \n");
}
$server = $row[0];
$url = "http://{$server}/dorf1.php";
$ch = my_curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
$all_id = parse_html($result);
$db_all = array();
$sql = "select id from villages where account = {$account}";
$res = mysql_query($sql);
if (!$res) {
die(mysql_error());
}
while ($row = mysql_fetch_row($res)) {
$id = $row[0];
array_push($db_all, $id);
}
foreach ($all_id as $id => $val) {
$name = mysql_escape_string($val[0]);
$x = $val[1];
$y = $val[2];
if (in_array($id, $db_all)) {
示例15: elseif
echo '</fieldset>' . "\n";
echo '</form>' . "\n";
} else {
echo 'nothing to do.';
}
// $file
} elseif (isset($_POST['valider']) and !empty($_FILES['file']['tmp_name'])) {
$message = array();
switch ($_POST['imp-format']) {
case 'jsonbak':
$json = file_get_contents($_FILES['file']['tmp_name']);
$message = importer_json($json);
break;
case 'htmllinks':
$html = file_get_contents($_FILES['file']['tmp_name']);
$message['links'] = insert_table_links(parse_html($html));
break;
case 'xmlwp':
$xml = file_get_contents($_FILES['file']['tmp_name']);
$message = importer_wordpress($xml);
break;
case 'rssopml':
$xml = file_get_contents($_FILES['file']['tmp_name']);
$message['feeds'] = importer_opml($xml);
break;
default:
die('nothing');
break;
}
if (!empty($message)) {
echo '<form action="maintenance.php" method="get" class="bordered-formbloc">' . "\n";