<?php
header("content-type:text/html;charset=utf-8");
session_start();
$ym=$_SERVER["HTTP_HOST"];
$ip=$_SERVER["REMOTE_ADDR"]; 
$sbxx=$_SERVER["HTTP_USER_AGENT"];
$zh=$_COOKIE["zh"];
$mm=$_COOKIE["mm"];
//转义
function zhuanyi($msg)
{
$msg=str_replace("[大于]","&gt;",$msg);
$msg=str_replace("[小于]","&lt;",$msg);
$msg=str_replace("[空格]","&nbsp;",$msg);
$msg=str_replace("[加]","+",$msg);
$msg=str_replace("[和]","&",$msg);
return str_replace("[换行]","<br>",$msg);
}
//转义1
function zhuanyi1($msg)
{
$msg=str_replace("&gt;",">",$msg);
$msg=str_replace("&lt;","<",$msg);
return str_replace("&nbsp;"," ",$msg);
}
//消息
function xiaoxi()
{
$xx=post("http://".$_SERVER["HTTP_HOST"]."/cl/cl.php","nr=消息");
return zhuanyi($xx);
}
//资料
function ziliao($zh)
{
$zl=post("http://".$_SERVER["HTTP_HOST"]."/cl/cl.php","nr=资料".$zh."");
return json_decode(zhuanyi($zl),true);
}
//图文
function tuwen($msg,$height,$size)
{
$tw=json_decode($msg,true);
return '<img src="'.$tw["img"].'" style="width:100%;height:'.$height.';border-radius:10px 10px 0 0;background:rgba(0,0,0,.5);"></img>
<div style="padding:0.5px;background:#eee;"></div>
<div class="kuang" style="font-size:'.$size.';border-radius:0 0 10px 10px;">'.$tw["neirong"].'</div>';
}
//新闻
function xinwen($msg)
{
$sl=preg_match_all("/".json_encode(array("img"=>"(.*?)","text"=>"(.*?)","url"=>"(.*?)"),JSON_UNESCAPED_UNICODE)."/",$msg,$xw);
for($xh=0;$xh<$sl;$xh++)
{
if($sl=="1")
{
return '<a href="'.$xw[3][$xh].'">
<div style="position:relative;">
<img src="'.$xw[1][$xh].'" style="width:100%;height:180px;border-radius:10px 10px 10px 10px;background:rgba(0,0,0,.5);"></img>
<div style="width:100%;position:absolute;text-align:center;font-size:1rem;color:#fff;bottom:0;padding:0.4rem;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;">'.$xw[2][$xh].'</div></div></a>';
}
else if($xh=="0")
{
$data='<a href="'.$xw[3][$xh].'">
<div style="position:relative;">
<img src="'.$xw[1][$xh].'" style="width:100%;height:180px;border-radius:10px 10px 0 0;background:rgba(0,0,0,.5);"></img>
<div style="width:100%;position:absolute;text-align:center;font-size:1rem;color:#fff;bottom:0;padding:0.4rem;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;">'.$xw[2][$xh].'</div></div></a>';
}
else if(($sl-1)==$xh)
{
return $data.'<div style="padding:0.5px;background:#eee;"></div>
<a href="'.$xw[3][$xh].'">
<div class="aui-card-list-header" style="border-radius:0 0 10px 10px;"><div>
<div class="aui-card-list-user-avatar">
<img src="'.$xw[1][$xh].'"></img>
</div><div style="padding-top:10px;font-size:0.8rem;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;">'.$xw[2][$xh].'</div>
</div></div></a>';
}
else
{
$data=$data.'<div style="padding:0.5px;background:#eee;"></div>
<a href="'.$xw[3][$xh].'">
<div class="aui-card-list-header"><div>
<div class="aui-card-list-user-avatar">
<img src="'.$xw[1][$xh].'"></img>
</div><div style="padding-top:10px;font-size:0.8rem;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;">'.$xw[2][$xh].'</div>
</div></div></a>';
}
}
}
//url
function url($msg)
{
$url=array("com","cn","ml","top","vip","not","xyz","club","wang");
$url=implode("|",$url);
$url="/(((http|https|ftp|ftps)\:\/\/)[0-9a-zA-Z]+\.(".$url.")\/(.*))/";
if(preg_match($url,$msg))
{
if(strstr($msg,"http"))
{
$msg=preg_replace($url,"<a href=\"$1\">$1</a>",$msg);
}
else
{
$msg=preg_replace($url,"<a href=\"http://$1\">$1</a>",$msg);
}
}
return $msg;
}
//post
function post($url,$post)
{
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
return curl_exec($curl);
curl_close($curl);
}
//读取文件
function duqu($msg)
{
if(file_exists($msg))
{
$file=file($msg);
return $file[0];
}
else
{
return "0";
}
}
//删除文件
function shanchu($msg)
{
if(file_exists($msg))
{
unlink($msg);
return "1";
}
}
//创建文件夹
function chuangjian($msg)
{
if(empty(is_dir($msg)))
{
mkdir($msg);
return "1";
}
}
//弹窗
function tc($text)
{
echo '<script language="javascript">alert("'.$text.'");</script>';
}
//跳转
function tz($url)
{
exit('<script language="javascript">window.location.href="'.$url.'";</script>');
}
//弹窗跳转
function tctz($text,$url)
{
exit('<script language="javascript">alert("'.$text.'");window.location.href="'.$url.'";</script>');
}
?>