⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.inc.php

📁 学校网站源码http://您的网址/admin/admin_login.asp 默认登录用户:admin 默认登录密码:admin
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php


class pages
{

	var $output;
	var $file;
	var $pvar = "page";
	var $psize;
	var $curr;
	var $varstr;
	var $tpage;

	function set( $pagesize = 20, $total, $current = false )
	{
		global $HTTP_SERVER_VARS;
		global $HTTP_GET_VARS;
		$this->total = $total;
		$this->tpage = ceil( $total / $pagesize );
		if ( !$current )
		{
			$current = $_REQUEST[$this->pvar];
		}
		if ( $this->tpage < $current )
		{
			$current = $this->tpage;
		}
		if ( $current < 1 )
		{
			$current = 1;
		}
		$this->curr = $current;
		$this->psize = $pagesize;
		if ( !$this->file )
		{
			$this->file = $HTTP_SERVER_VARS['PHP_SELF'];
		}
		if ( 0 < $this->tpage )
		{
			$this->output .= "<table cellspacing=1><tr>";
			if ( 10 < $current )
			{
				$this->output .= ( "<td style=\"padding-left:3px;padding-right:3px\"><a class=pages href=".$this->file."?".$this->pvar."=".( $current - 10 ) ).$this->varstr." title=\"前十页\"><img src=images/2arrow_l_on.gif border=0></a></td>";
			}
			else
			{
				$this->output .= "<td><img src=images/2arrow_l_off.gif border=0></td>";
			}
			if ( 1 < $current )
			{
				$this->output .= ( "<td  style=\"padding-left:3px;padding-right:3px\"><a  class=pages href=".$this->file."?".$this->pvar."=".( $current - 1 ) ).$this->varstr." title=\"前一页\"><img src=images/1arrow_l_on.gif border=0></a></td><td width=3></td>";
			}
			else
			{
				$this->output .= "<td><img src=images/1arrow_l_off.gif border=0></td><td width=3></td>";
			}
			if ( floor( $current / 10 ) == $current / 10 )
			{
				$start = floor( $current / 10 ) * 10 - 9;
			}
			else
			{
				$start = floor( $current / 10 ) * 10 + 1;
			}
			$end = $start + 9;
			if ( $start < 1 )
			{
				$start = 1;
			}
			if ( $this->tpage < $end )
			{
				$end = $this->tpage;
			}
			$i = $start;
			for ( ;	$i <= $end;	$i++	)
			{
				if ( $current == $i )
				{
					$this->output .= "<td class=pages style=\"color:red;TEXT-DECORATION: underline;padding-left:3px;padding-right:3px\" ><b>".$i."</b></td>";
				}
				else
				{
					$this->output .= "<td class=pages  style=\"padding-left:3px;padding-right:3px\"><b><a class=pages style=\"TEXT-DECORATION: underline\" href= \"".$this->file."?".$this->pvar."=".$i.$this->varstr."\">".$i."</a><b></td>";
				}
			}
			if ( $current < $this->tpage )
			{
				$this->output .= ( "<td width=3></td><td  style=\"padding-left:3px;padding-right:3px\"><a class=pages  href=".$this->file."?".$this->pvar."=".( $current + 1 ) ).$this->varstr." title=\"下一页\"><img src=images/1arrow_r_on.gif border=0></a></td>";
			}
			else
			{
				$this->output .= "<td width=3></td><td><img src=images/1arrow_r_off.gif border=0></td>";
			}
			if ( 10 < $this->tpage && 10 <= $this->tpage - $current )
			{
				$this->output .= ( "<td><a class=pages  href=".$this->file."?".$this->pvar."=".( $current + 10 ) ).$this->varstr." title=\"下十页\"><img src=images/2arrow_r_on.gif border=0></a></td>";
			}
			else
			{
				$this->output .= "<td><img src=images/2arrow_r_off.gif border=0></td>";
			}
			$this->output .= "</tr></table>";
		}
	}

	function setvar( $data )
	{
		foreach ( $data as $k => $v )
		{
			$this->varstr .= "&amp;".$k."=".urlencode( $v );
		}
	}

	function output( $return = false )
	{
		if ( $return )
		{
			return $this->output;
		}
		else
		{
			echo $this->output;
		}
	}

	function limit( )
	{
		return ( $this->curr - 1 ) * $this->psize.",".$this->psize;
	}

	function shownow( )
	{
		global $strPagesTotalStart;
		global $strPagesTotalEnd;
		global $strPagesNowPagesFrom;
		global $strPagesNowPagesTo;
		global $strPagesNowListFrom;
		global $strPagesNowListTo;
		if ( $this->total <= ( $this->curr - 1 ) * $this->psize + $this->psize )
		{
			echo ( $strPagesTotalStart.$this->total.$strPagesTotalEnd." ".$strPagesNowPagesFrom.$this->curr.$strPagesNowPagesTo." ".$strPagesNowListFrom.( ( $this->curr - 1 ) * $this->psize + 1 ) )."-".$this->total.$strPagesNowListTo;
		}
		else
		{
			echo ( $strPagesTotalStart.$this->total.$strPagesTotalEnd." ".$strPagesNowPagesFrom.$this->curr.$strPagesNowPagesTo." ".$strPagesNowListFrom.( ( $this->curr - 1 ) * $this->psize + 1 ) )."-".( ( $this->curr - 1 ) * $this->psize + $this->psize ).$strPagesNowListTo;
		}
	}

}

function fmpath( $catid )
{
	if ( strlen( $catid ) == 1 )
	{
		$pathid = "000".$catid;
	}
	else if ( strlen( $catid ) == 2 )
	{
		$pathid = "00".$catid;
	}
	else if ( strlen( $catid ) == 3 )
	{
		$pathid = "0".$catid;
	}
	else if ( 4 <= strlen( $catid ) )
	{
		$pathid = $catid;
	}
	return $pathid;
}

function popback( $reson, $self )
{
	echo "<script>alert(\"{$reson}\");\r\n\tself.location='".$self."';\r\n\t</script>";
	exit( );
}

function readconfig( )
{
	global $msql;
	global $tbl_config;
	global $CONF;
	$msql->query( "select * from {$tbl_config}" );
	while ( $msql->next_record( ) )
	{
		$variable = $msql->f( "variable" );
		$value = $msql->f( "value" );
		$CONF[$variable] = $value;
	}
}

function tblcount( $tbl, $id, $scl )
{
	global $msql;
	$msql->query( "select count(".$id.") from {$tbl} where {$scl}" );
	if ( $msql->next_record( ) )
	{
		$totalnums = $msql->f( "count(".$id.")" );
	}
	return $totalnums;
}

function csubstr( $str, $start, $len, $dot )
{
	$strlen = strlen( $str );
	if ( $strlen <= $start )
	{
		return $str;
	}
	$clen = 0;
	$i = 0;
	for ( ;	$i < $strlen;	$i++,	$clen++	)
	{
		if ( 160 < ord( substr( $str, $i, 1 ) ) )
		{
			if ( $start <= $clen )
			{
				$tmpstr .= substr( $str, $i, 3 );
			}
			$i++;
		}
		else if ( $start <= $clen )
		{
			$tmpstr .= substr( $str, $i, 1 );
		}
		if ( $start + $len <= $clen )
		{
			break;
		}
	}
	if ( $dot == 1 && $str != $tmpstr )
	{
		$tmpstr = $tmpstr."...";
	}
	return $tmpstr;
}

function seld( $t, $z )
{
	if ( $t == $z )
	{
		$ret = " selected";
	}
	else
	{
		$ret = " ";
	}
	return $ret;
}

function err( $say, $url, $link )
{
	global $strBack;
	if ( $url == "" )
	{
		$url = "Javascript:history.back();";
	}
	if ( $link == "" )
	{
		$link = $strBack;
	}
	echo "<br><br><table width=366 border=0 cellspacing=2 cellpadding=6 align=center bgcolor=#FFFFFF background=images/err.gif height=199>\r\n  <tr align=center> \r\n    <td height=80 valign=bottom><img src=images/alert.gif></td>\r\n  </tr>\r\n  <tr> \r\n    <td > \r\n      <div align=center> \r\n        <p style='font-size:12px;color:#333333'>".$say." </p>\r\n      </div>\r\n    </td>\r\n  </tr>\r\n  <tr> \r\n    <td height=50 align=center><a href=".$url." style='font-size:12px;color:#ff6600'>[".$link."]</a></td>\r\n  </tr>\r\n</table>";
	exit( );
}

function sayok( $say, $url, $link )
{
	global $strBack;
	if ( $url == "" )
	{
		$url = "Javascript:history.back();";
	}
	if ( $link == "" )
	{
		$link = $strBack;
	}
	echo "<br><br><table width=366 border=0 cellspacing=2 cellpadding=6 align=center bgcolor=#FFFFFF background=images/err.gif height=199>\r\n  <tr align=center> \r\n    <td height=80 valign=bottom><img src=images/ok.gif></td>\r\n  </tr>\r\n  <tr> \r\n    <td > \r\n      <div align=center> \r\n        <p>".$say." </p>\r\n      </div>\r\n    </td>\r\n  </tr>\r\n  <tr> \r\n    <td height=50 align=center><a href=".$url.">[".$link."]</a></td>\r\n  </tr>\r\n</table>";
	exit( );
}

function checked( $t, $z )
{
	if ( $t == $z )
	{
		$ret = " checked";
	}
	else
	{
		$ret = " ";
	}
	return $ret;
}

function addcatnums( $tbl, $catpath )
{
	global $msql;
	$array = explode( ":", $catpath );
	$n = sizeof( $array ) - 1;
	$k = 0;
	for ( ;	$k < $n;	$k++	)
	{
		$arr = $array[$k] + 0;
		$msql->query( "update {$tbl} set nums=nums+1 where catid='{$arr}'" );
	}
}

function mincatnums( $tbl, $catpath )
{
	global $msql;
	$array = explode( ":", $catpath );
	$n = sizeof( $array ) - 1;
	$k = 0;
	for ( ;	$k < $n;	$k++	)
	{
		$arr = $array[$k] + 0;
		$msql->query( "update {$tbl} set nums=nums-1 where catid='{$arr}' and nums>0" );
	}
}

function menufold( $menuid )
{
	global $msql;
	global $tbl_menu;
	$msql->query( "select * from {$tbl_menu} where menuid='{$menuid}'" );
	if ( $msql->next_record( ) )
	{
		$fold = $msql->f( "fold" );
	}
	return $fold;
}

function menuid2menu( $menuid )
{
	global $msql;
	global $tbl_menu;
	$msql->query( "select * from {$tbl_menu} where menuid='{$menuid}'" );
	if ( $msql->next_record( ) )
	{
		$menu = $msql->f( "menu" );
	}
	return $menu;
}

function catid2menuid( $tblcat, $catid )
{
	global $msql;
	$msql->query( "select menuid from {$tblcat} where catid='{$catid}'" );
	if ( $msql->next_record( ) )
	{
		$menuid = $msql->f( "menuid" );
	}
	return $menuid;
}

function cattree( $selmenuid, $url, $tblcat, $coltype )
{
	global $msql;
	global $fsql;
	global $tbl_menu;
	$FormString = "";
	$FormString .= "<table width=100% border=0 cellspacing=3 cellpadding=0><tr><td class=dtree>";
	$FormString .= "<script type=text/javascript src=js/dirtree.js></script>";
	$FormString .= "<script  type=text/javascript> <!-- \n";
	$FormString .= "function dtree(){";
	$FormString .= "d = new dTree('d');";
	$p = 0;
	$fsql->query( "select * from {$tbl_menu} where coltype='{$coltype}' order by xuhao" );
	while ( $fsql->next_record( ) )
	{
		$menu = $fsql->f( "menu" );
		$menuid = $fsql->f( "menuid" );
		if ( $p == "0" && $selmenuid == "" )
		{
			$selmenuid = $menuid;
		}
		$p++;
		$FormString .= "d.add({$menuid},-1,'".$menu."','{$url}?menuid={$menuid}&pid=0'); \n";
		$msql->query( "select * from {$tblcat} where menuid='{$menuid}' order by xuhao" );
		while ( $msql->next_record( ) )
		{
			$catid = $msql->f( "catid" );
			$pid = $msql->f( "pid" );
			$cat = $msql->f( "cat" );
			$nums = $msql->f( "nums" );
			$cat = str_replace( "'", "", $cat );
			$cat = substr( $cat, 0, 18 );
			$nowid = $catid + 10000;
			$nowpid = $pid + 10000;
			if ( $pid == "0" || $pid == "" )
			{
				$FormString .= "d.add({$nowid},{$menuid},'{$cat}','{$url}?menuid={$menuid}&pid={$catid}'); \n";
			}
			else
			{
				$FormString .= "d.add({$nowid},{$nowpid},'{$cat}','{$url}?menuid={$menuid}&pid={$catid}'); \n";
			}
		}
	}
	$FormString .= "document.write(d); } \n //--></script><script>dtree();</script>";
	$FormString .= "</td></tr></table>";
	echo $FormString;
	return $selmenuid;
}

function htmtree( )
{
	global $msql;
	global $fsql;
	global $tbl_menu;
	$FormString = "";
	$FormString .= "<table width=100% border=0 cellspacing=3 cellpadding=0><tr><td class=dtree>";
	$FormString .= "<script type=text/javascript src=js/dirtree.js></script>";
	$FormString .= "<script  type=text/javascript> <!-- \n";
	$FormString .= "function dtree(){";
	$FormString .= "d = new dTree('d');";
	$FormString .= "d.add(0,-1,'".$strHtmManage."','0.htm'); \n";
	$fsql->query( "select * from {$tbl_menu} where coltype='htm' order by xuhao" );
	while ( $fsql->next_record( ) )
	{
		$menu = $fsql->f( "menu" );
		$menuid = $fsql->f( "menuid" );
		$FormString .= "d.add({$nowid},{$nowpid},'{$cat}','{$url}?menuid={$menuid}&pid={$catid}'); \n";
	}
	$FormString .= "document.write(d); } \n //--></script><script>dtree();</script>";
	$FormString .= "</td></tr></table>";
	echo $FormString;
	return $selmenuid;
}

function catid2cat( $catid, $tbl )
{
	global $fsql;
	global $menuid;
	$menu = menuid2menu( $menuid );
	$str = $menu." &gt; ";
	if ( $catid != "" && $catid != "0" )
	{
		$fsql->query( "select catpath from {$tbl} where catid='{$catid}'" );
		if ( $fsql->next_record( ) )
		{
			$catpath = $fsql->f( "catpath" );
		}
		$arr = explode( ":", $catpath );
		$num = sizeof( $arr ) - 1;
		$i = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -