db($mydbhost,$mydbuser,$mydbpw,$mydbname);//调用连接数据库函数 include_once('phone/class/action.class.php');//调用动作处理类 $action = new action();//实例化对像 include_once('phone/class/page.class.php');//调用动作处理类 $htmlPage=new page(); ?> $len) { $str .= "..."; break; } elseif((ord(substr($string , $i , 1)) <= 128) && ($count < $start)) { $count++; } elseif((ord(substr($string , $i , 1)) > 128) && ($count < $start)) { $count = $count + 2; $i = $i + $byte-1; } elseif((ord(substr($string , $i , 1)) <= 128) && ($count >= $start)) { $str .= substr($string , $i , 1); $count++; } elseif((ord(substr($string , $i , 1)) > 128) && ($count >= $start)) { $str .= substr($string , $i , $byte); $count = $count + 2; $i = $i + $byte - 1; } } return $str; } //长文章分页 function remove_xss($val) { $val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val); $search = 'abcdefghijklmnopqrstuvwxyz'; $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $search .= '1234567890!@#$%^&*()'; $search .= '~`";:?+/={}[]-_|\'\\'; for ($i = 0; $i < strlen($search); $i++) { $val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); // with a ; $val = preg_replace('/(�{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); // with a ; } $ra1 = array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base'); $ra2 = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload'); $ra = array_merge($ra1, $ra2); $found = true; // keep replacing as long as the previous round replaced something while ($found == true) { $val_before = $val; for ($i = 0; $i < sizeof($ra); $i++) { $pattern = '/'; for ($j = 0; $j < strlen($ra[$i]); $j++) { if ($j > 0) { $pattern .= '('; $pattern .= '(&#[xX]0{0,8}([9ab]);)'; $pattern .= '|'; $pattern .= '|(�{0,8}([9|10|13]);)'; $pattern .= ')*'; } $pattern .= $ra[$i][$j]; } $pattern .= '/i'; $replacement = substr($ra[$i], 0, 2).''.substr($ra[$i], 2); // add in <> to nerf the tag $val = preg_replace($pattern, $replacement, $val); // filter out the hex tags if ($val_before == $val) { // no replacements were made, so exit the loop $found = false; } } } return $val; } function article_addpage($article,$word_number=2000) { //===本函数的作用是按照字节数给文章增加分页代码 //作者:www.52link.net 叶藤 //QQ:383569 //演示效果: www.52fengshou.cn //本程序为共享程序,请尊重作者劳动和版权法,任何人不得将此程序用于商业 //转载、发布本程序,请务必保留作者版权信息,请支持原创 //部分变量说明: //$art_num 确定段落数 //$artinfo[$i] 段落内容 //$page_num_word[$i] 段落字节 //$word_number每段字数 //$weor_cha=浮动字数 $con = explode("1){ return $article; //如果包含了表格就跳过,不进行分页处理 }else{ $word_all=""; $word_num=0; $n=""; $weor_cha=($word_number/10);//(上下浮动每页字数的10%) $article=preg_replace("//m", "
", $article); $article= str_replace("","", $article); $article=preg_replace("//m", "
", $article); $article= str_replace("","", $article); $article=preg_replace("//m", "
", $article); $article= str_replace("

","", $article); $article= str_replace(chr(10),"
", $article); $article=preg_replace("/<(.*?)
(.*?)>/m", "<\\1 \\2>", $article); $artinfo=split("
",$article);//根据字符串确定段落 $art_num=count($artinfo);//确定段落数 $page_num_word=array(); for($i=0;$i<=$art_num-1;$i++) { $page_num_word[$i]=strlen($artinfo[$i]); $word_num=$word_num+$page_num_word[$i];//得到字数 if ($word_num-$weor_cha<=$word_number or $i==0){ $word_all.=$artinfo[$i]."
"; }else{ $word_all.="[nextpage]
".$artinfo[$i]; $word_num=0; } } return $word_all; }//=========if 表格 } function article_fenpage($article,$id,$page) { $artinfo=explode("[nextpage]",$article);//根据字符串确定段落 $pages=count($artinfo);//确定段落数 $tempurla=""; $fenyedh=""; // echo $pages; //=======================================分页导航 //显示总页数 if (intval($pages)>1){ $fenyedh= $fenyedh.'
共有'.$pages.'页 '; $substart=$page-10; $sybend=$page+10; if ($substart<=1 ){ $substart=1; } if ($sybend>=$pages ){ $sybend=$pages; } //显示分页数 $first=1; $prev=$page-1; if($prev=="0") $prev=1; $next=$page+1; if($next>$pages) $next=$pages; $last=$pages; // $fenyedh= $fenyedh."第一页 "; $fenyedh= $fenyedh."上一页 "; for ($i=$substart;$i<$page;$i++){ $fenyedh= $fenyedh."[".$i."] "; } $fenyedh= $fenyedh."[".$page."]"; for ($i=$page+1;$i<=$sybend;$i++){ $fenyedh= $fenyedh."[".$i."] ";} $fenyedh= $fenyedh."下一页 "; $fenyedh= $fenyedh."最后一页"; $fenyedh= $fenyedh."
"; } //=======================================分页导航end return $artinfo[$page-1]."
".$fenyedh; } //============================================ //获取字符串 function getstr($string, $length, $in_slashes=0, $out_slashes=0, $censor=0, $bbcode=0, $html=0) { $string = trim($string); if($html < 0) { //去掉html标签 $string = preg_replace("/(\<[^\<]*\>|\r|\n|\s|\[.+?\])/is", ' ', $string); $string = shtmlspecialchars($string); } elseif ($html == 0) { //转换html标签 $string = shtmlspecialchars($string); } if($length && strlen($string) > $length) { //截断字符 $wordscut = ''; if(strtolower($_SC['charset']) == 'utf-8') { //utf8编码 $n = 0; $tn = 0; $noc = 0; while ($n < strlen($string)) { $t = ord($string[$n]); if($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) { $tn = 1; $n++; $noc++; } elseif(194 <= $t && $t <= 223) { $tn = 2; $n += 2; $noc += 2; } elseif(224 <= $t && $t < 239) { $tn = 3; $n += 3; $noc += 2; } elseif(240 <= $t && $t <= 247) { $tn = 4; $n += 4; $noc += 2; } elseif(248 <= $t && $t <= 251) { $tn = 5; $n += 5; $noc += 2; } elseif($t == 252 || $t == 253) { $tn = 6; $n += 6; $noc += 2; } else { $n++; } if ($noc >= $length) { break; } } if ($noc > $length) { $n -= $tn; } $wordscut = substr($string, 0, $n); } else { for($i = 0; $i < $length - 1; $i++) { if(ord($string[$i]) > 127) { $wordscut .= $string[$i].$string[$i + 1]; $i++; } else { $wordscut .= $string[$i]; } } } $string = $wordscut; } if($out_slashes) { $string = saddslashes($string); } return trim($string); } //取消HTML代码 function shtmlspecialchars($string) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = shtmlspecialchars($val); } } else { $string = preg_replace('/&((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/', '&\\1', str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>','

'), $string)); } return $string; } //生成xml文件 function createxml($arr,$save_url){ $doc = new DOMDocument('1.0', 'utf-8'); // 声明版本和编码 $doc -> formatOutput = true; //格式XML输出 $bcaster = $doc -> createElement('bcaster'); //创建一个标签 $autoPlayTime = $doc -> createAttribute('autoPlayTime'); //创建一个idd属性 $time = $doc -> createTextNode("6"); //设置播放属性时间 foreach($arr as $key => $value){ $item = $doc -> createElement('item'); //创建一个item标签 $itemco = $doc -> createTextNode(""); //设置标签内容 $item_url = $doc -> createAttribute('item_url'); //创建一个url属性 $url = $doc -> createTextNode($value[item_url]); //设置url地址 $link = $doc -> createAttribute('link'); //创建一个link属性 $link_v = $doc -> createTextNode($value[link]); //设置link地址 $item_url -> appendChild($url); //继承url属性 $item -> appendChild($item_url); //继承url属性内容 $link -> appendChild($link_v); //继承link属性 $item -> appendChild($link); //继承link属性内容 $autoPlayTime -> appendChild($time); //继承autoplaytime属性 $bcaster -> appendChild($autoPlayTime); //继承autoplaytime属性内容 $bcaster -> appendChild($item); //继承item标签 $item -> appendChild($itemco); //继承标签内容 $doc -> appendChild($bcaster); } $doc -> save($save_url); // 生成保存为XML } function showAlert($showAlert_mes,$showAlert_num,$showAlert_url) { $showAlert_show=''; $showAlert_num=="1"?$showAlert_show="":$showAlert_show=""; $showAlert=$showAlert_show; exit; } function getName($getValue) { $showValue='无设置'; switch($getValue) { case 'about':$showValue='关于我们'; break; case 'product':$showValue='产品中心'; break; case 'news':$showValue='新闻新闻'; break; case 'contact':$showValue='联系我们'; break; case 'join':$showValue='加入我们'; break; case 'technology':$showValue='技术专栏'; break; case 'message':$showValue='在线留言'; break; case 'departments':$showValue='部门管理'; break; case 'ad':$showValue='切换图'; break; } return $showValue; } function showmsg($showtxt,$surl) { echo ""; exit; } ?>