• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2939
  • Last Modified:

Invalid argument supplied for foreach()

I get the following error after migrating a site to new server :

Warning: Invalid argument supplied for foreach() in /..path../lib.php on line 22

I have included lib.php below, does anyone know how to fix it?

Thanks.
<?
/******************************************************************************
 * Zeroboard library 
 *
 * FÖ^ ±‘~à : 2006. 3. 15
 * œ Ô~Ö Å ± 3|[ N ¨|w+ Lòû.
 *
 * by zero (zero@nzeo.com)
 *
 ******************************************************************************/
 
    // W3C P3P XÒ²‘
    @header ("P3P : CP=\"ALL CURa ADMa DEVa TAIa OUR BUS IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC OTC\"");
 
	// £ß WÒ
	$zb_version = "4.1 pl8";
 
	/*******************************************************************************
 	 * ] lÓ ²‘A register_globals_on~} ò± ß ‘Ö
 	 ******************************************************************************/
 	@error_reporting(E_ALL ^ E_NOTICE);
        foreach($HTTP_GET_VARS as $key=>$val) $$key = del_html($val);
	@extract($HTTP_POST_VARS); 
	@extract($HTTP_SERVER_VARS); 
	@extract($HTTP_ENV_VARS);
 
        $page = (int)$page;
 
	$temp_filename=realpath(__FILE__);
	if($temp_filename) $config_dir=eregi_replace("lib.php","",$temp_filename);
	else $config_dir="";
 
	/*******************************************************************************
 	 * fD ò± þf÷. (phpÖ ƒß}Ö JÎ ƒß }å;; ))+)
 	 ******************************************************************************/
	unset($member);
	unset($group);
	unset($setup);
 
	/*******************************************************************************
 	 * include NwÖ‚ 
 	 ******************************************************************************/
	if(defined("_zb_lib_included")) return;
    define("_zb_lib_included",true);
 
	$_startTime=getmicrotime();
 
	/*******************************************************************************
 	 * fD ²‘ Ô~Ê —à
 	 ******************************************************************************/
 	$_zbDefaultSetup = getDefaultSetup();
 
	/*******************************************************************************
 	 * install ôœÖ[ 4Ë 3¦
 	 ******************************************************************************/
	if(!eregi("install",$PHP_SELF)&&file_exists($_zb_path."config.php")) {
 
 	 	//®® @l (®®Î 3~Õð ¸	|j ²‘)
		if(!is_dir($_zb_path.$_zbDefaultSetup[session_path])) {
			mkdir($_zb_path.$_zbDefaultSetup[session_path], 0777);
			chmod($_zb_path.$_zbDefaultSetup[session_path], 0777);
		}
 
		// Data, Icon, ®®äÓ\lÖ Yf ~œ HûÊ ] @l
		if(!is_writable($_zb_path."data")) error("!Õ(dataÇ™>ëeÇ™<br>(ZeroboardËfˆdataÇ™>„ëe
P");
		if(!is_writable($_zb_path."icon")) error("!Õ(iconÇ™>ëeÇ™<br>(ZeroboardËfˆiconÇ™>„ëe
P");
		if(!is_writable($_zb_path.$_zbDefaultSetup[session_path])) error("!Õ(sessionÇ™>(".$_zb_path.$_zbDefaultSetup[session_path].")ëeÇ™<br>(ZeroboardËfˆsessionÇ™>„ëe
P");
 
		$_sessionStart = getmicrotime();
		@session_save_path($_zb_path.$_zbDefaultSetup[session_path]);
		@session_cache_limiter('nocache, must_revalidate');
 
		session_set_cookie_params(0,"/");
 
		// ®® ò±Ö ÔY
		@session_start();
		// added by sbluo start
		$this->sid = session_id();
		$sessionid = $this->sid;
		// added by sbluo end
 
		// ;± [ 512byte‚, qR ®®ò±[ 256byte‚ iÊ[ l¢ (C£®W‚ œ¨[ ;Î & ú¥+ >)
		if(strlen($HTTP_SESSION_VARS[zb_hit])>$_zbDefaultSetup[session_view_size]) {
			$zb_hit='';
			session_register("zb_hit");
		}
		if(strlen($HTTP_SESSION_VARS[zb_vote])>$_zbDefaultSetup[session_vote_size]) {
			$zb_vote='';
			session_register("zb_vote");
		}
 
		// àÕ Nœ£~} ¯ N 9 àÕ Nœ££Ö ¹ü| aŸ
		unset($autoLoginData);
		$autoLoginData = getZBSessionID();
		if($autoLoginData[no]) {
			$zb_logged_no=$autoLoginData[no];
			// added by sbluo start, 01142005
			$zb_logged_ip=$sessionid;
			// added by sbluo end, 01142005
			$zb_logged_time=time();
			session_register("zb_logged_no");
			session_register("zb_logged_ip");
			session_register("zb_logged_time");
			$HTTP_SESSION_VARS["zb_logged_no"] = $zb_logged_no;
 
		// ®® ØÊ ¹ü|y Nœ£Ê @l
		} elseif($HTTP_SESSION_VARS["zb_logged_no"]) {
 
			// Nœ£ [dœ Ö‘9 [dÊ iwjí Nœ£ 4œt[ £ß ¨àÖ 4œtæ û‚ 3¦ Nœ4’ [=
			// added by sbluo start, 01142005
			if(time()-$HTTP_SESSION_VARS["zb_logged_time"]>$_zbDefaultSetup["login_time"]||$HTTP_SESSION_VARS["zb_logged_ip"]!=$sessionid) {
			// added by sbluo end, 01142005
 
				$zb_logged_no="";
				$zb_logged_time="";
				$zb_logged_ip="";
				session_register("zb_logged_no");
				session_register("zb_logged_ip");
				session_register("zb_logged_time");
				session_destroy();
 
			// ¸	 3¦ Nœ£ [dÊ û[ ²‘
			} else {
				// 4.0x ¨ ®® @l
				$zb_logged_time=time();
				session_register("zb_logged_time");
			}
 
		} 
		$_sessionEnd = getmicrotime();
 
		// £ß ~àÖ Iœk‚ ¹ü|y Ô~N êð (3,  32N ˜Ÿ…® êð)
		$_nowConnectStart = getmicrotime();
		if($_zbDefaultSetup[nowconnect_enable]=="true") {
			$_zb_now_check_intervalTime = time()-$HTTP_SESSION_VARS["zb_last_connect_check"];
 
			if(!$HTTP_SESSION_VARS["zb_last_connect_check"]||$_zb_now_check_intervalTime>$_zbDefaultSetup[nowconnect_refresh_time]) {
 
				// 4.0x ¨ ®® @l
				$zb_last_connect_check = time();
				session_register("zb_last_connect_check");
 
				if($HTTP_SESSION_VARS["zb_logged_no"]) {
					$total_member_connect = $total_connect = getNowConnector($_zb_path."data/now_member_connect.php",$HTTP_SESSION_VARS[zb_logged_no]);
					$total_guest_connect = getNowConnector_num($_zb_path."data/now_connect.php", TRUE);
				} else {
					$total_member_connect = $total_connect = getNowConnector_num($_zb_path."data/now_member_connect.php", TRUE);
					$total_guest_connect = getNowConnector($_zb_path."data/now_connect.php",$REMOTE_ADDR);
				}
			} else {
				$total_member_connect = $total_connect = getNowConnector_num($_zb_path."data/now_member_connect.php",FALSE);
				$total_guest_connect = getNowConnector_num($_zb_path."data/now_connect.php",FALSE);
			}
 
		}
 
	}
 
	$_nowConnectEnd = getmicrotime();
 
	// config.php Ô~Ö *‚‚ ˜;;
	$temp_filename=realpath(__FILE__);
	if($temp_filename) $config_dir=eregi_replace("lib.php","",$temp_filename);
	else $config_dir="";
 
 
	// Ûvæ ˜v¨œn~} @l
	if(eregi("msie",$HTTP_USER_AGENT)) $browser="1"; else $browser="0";
 
 
	// DB[ ²‘œ NwÖ‚ 
	if(!file_exists($config_dir."config.php")&&!eregi("install",$PHP_SELF)) {
 		echo"<meta http-equiv=\"refresh\" content=\"0; url=install.php\">";
 		exit;
	}
 
 
	// flà ”œ°A 3fl ”œ°Ö œwÊ l ò±N ‘Ö
	$member_table = "zetyx_member_table";  // 3ßÖ Iœk[ ßk  ~³£ ”œ°
	$group_table = "zetyx_group_table";   // œ\”œ°
	$admin_table="zetyx_admin_table";     // j[×Ö flà ”œ°
 
	$send_memo_table ="zetyx_send_memo";
	$get_memo_table ="zetyx_get_memo";
 
	$t_division="zetyx_division"; // Division ”œ°
	$t_board = "zetyx_board"; // m£ ”œ°
	$t_comment ="zetyx_board_comment"; // Àn¾”œ°
	$t_category ="zetyx_board_category"; // ”l ”œ°
 
 
	// FœüN k\ ˜
	function getmicrotime() {
    	$microtimestmp = split(" ",microtime());
    	return $microtimestmp[0]+$microtimestmp[1];
	}
 
 
	/******************************************************************************
 	* Division f¼ ±
 	*****************************************************************************/
	// ª¹ division ˜
	function total_division() {
 		global $connect, $t_division, $id;
 		$temp=mysql_fetch_array(mysql_query("select max(division) from $t_division"."_$id"));
 		return $temp[0];
	}
 
	// /Ë~} …! divisionÖ num Ø ¸[
	function plus_division($division) {
		global $connect, $t_division, $id;
		mysql_query("update $t_division"."_$id set num=num+1 where division='$division'") or error(mysql_error);
	}
 
	// 	¯|jí bÖËÊ ~iËN af ÔÖ division numØ ò÷[ …! divisionÖ numØ ¬![=
	function minus_division($division) {
		global $connect, $t_division, $id;
		mysql_query("update $t_division"."_$id set num=num-1 where division='$division'") or error(mysql_error);
	}
 
 
	// XËYf~} F¬ divisionÖ num Ø ¸[
	function add_division($board_name="") {
		global $connect, $t_division, $id, $t_board;
		if($board_name) $board_id=$board_name;
		else $board_id=$id;
		$temp=mysql_fetch_array(mysql_query("select num from $t_division"."_$board_id order by division desc limit 1"));
 
		// £ß divisionÖ numØœ f}Ø~} division +1 …€;
		if($temp[0]>=5000) {
			$temp=mysql_fetch_array(mysql_query("select max(division) from $t_division"."_$board_id"));
			$max_division=$temp[0]+1;
			$temp=mysql_fetch_array(mysql_query("select max(division) from $t_division"."_$board_id where num>0 and division!='$max_division'"));
			if(!$temp[0]) $second_division=0; else $second_division=$temp[0];
			$temp=mysql_fetch_array(mysql_query("select count(*) from $t_board"."_$board_id where (division='$max_division' or division='$second_division') and headnum<=-2000000000"));
			if($temp[0]>0) {
				mysql_query("update $t_board"."_$board_id set division='$max_division' where (division='$max_division' or division='$second_division') and  headnum<='-2000000000'") or error(mysql_error());
				mysql_query("update $t_division"."_$board_id set num=num-$temp[0] where division=$max_division-1") or error(mysql_error());
			}
			$num=$temp[0]+1;
			mysql_query("insert into $t_division"."_$board_id (division,num) values ('$max_division','$num')");
			return $max_division;
		} else {
 		// £ß divisionœ f}ØC>û ÛÊ}~
			$temp=mysql_fetch_array(mysql_query("select max(division) from $t_division"."_$board_id"));
			$division=$temp[0];
			mysql_query("update $t_division"."_$board_id set num=num+1 where division='$division'");
			return $division;
		}
	}
 
 
	/******************************************************************************
 	* Nœ£œ Nk Ö‚ |y Nœ£Nk2Ê …! 3Ö ‘>‚ êð
 	*****************************************************************************/
	function member_info() {
 
		global $HTTP_SESSION_VARS, $member_table, $REMOTE_ADDR, $member, $connect;
 
		if(defined("_member_info_included")&&$member[no]) return $member;
		define("_member_info_included", true);
 
		if($member[no]) return $member;
 
		if($HTTP_SESSION_VARS["zb_logged_no"]) {
			$member=mysql_fetch_array(mysql_query("select * from $member_table where no ='".$HTTP_SESSION_VARS["zb_logged_no"]."'"));
			if(!$member[no]) {
				unset($member);
				$member[level] = 10;
			}
		} else $member[level] = 10;
 
		return $member;
	}
 
 
	function group_info($no) {
		global $group_table;
		$temp=mysql_fetch_array(mysql_query("select * from $group_table where no='$no'"));
		return $temp;
	}
 
 
 
	/******************************************************************************
 	* ¯N> ª¨ ±
 	*****************************************************************************/
	// MySQL Iœk œv ~¬
	function dbconn() {
 
		global $connect, $config_dir, $autologin, $HTTP_COOKIE_VARS, $_dbconn_is_included;
 
		if($_dbconn_is_included) return;
		$_dbconn_is_included = true;
 
		$f=@file($config_dir."config.php") or Error("config.php
X(<br>ËH-šÇ™«","install.php");
 
		for($i=1;$i<=4;$i++) $f[$i]=trim(str_replace("\n","",$f[$i]));
 
		if(!$connect) $connect = @mysql_connect($f[1],$f[2],$f[3]) or Error("#¥Ç™«BúþOL");
 
		@mysql_select_db($f[4], $connect) or Error("(„Ç™«úþOL","");
	
		return $connect;
	}
 
 
	// ËÖ 4œÊ {4€;;
	function get_icon($data) {
		global $dir;
 
		// Ëy [d ˜
		$check_time=((time() + (2 * 60 * 60))-$data[reg_date])/60/60;
 
		// Å 1 4œ ‘Ö
		if($data[depth]) {
			if($check_time<=12) $icon="<img src=$dir/reply_new_head.gif border=0 align=absmiddle>&nbsp;"; // F¬ Ë~3¦
			else $icon="<img src=$dir/reply_head.gif border=0 align=absmiddle>&nbsp;"; // /Ë~}
		} else {
			if($check_time<=12) $icon="<img src=$dir/new_head.gif border=0 align=absmiddle>&nbsp;"; // F¬ Ë~3¦
			else $icon="<img src=$dir/old_head.gif border=0 align=absmiddle>&nbsp;";          // /Ëœ 4Í}
		}
		if($data[headnum]<=-2000000000) $icon="<img src=$dir/notice_head.gif border=0 align=absmiddle>&nbsp;"; // bÖ„~}
		else if($data[is_secret]==1) $icon="<img src=$dir/secret_head.gif border=0 align=absmiddle alt='„„q'>&nbsp;";
		return $icon;
	}
 
 
	// 3 C£j ?kÖ 4œÊ Ê ±
	// $type : 1 -> œwÅ íkí 4œ
	// $type : 2 -> œwÊ  | 4œ
	function get_private_icon($no, $type) {
		if($type==1) $dir = "icon/private_icon/";
		elseif($type==2) $dir = "icon/private_name/";
 
		if(@file_exists($dir.$no.".gif")) return $dir.$no.".gif";
	}
 
 
	// œw Å 1 a‰ 4œ
	function get_face($data, $check=0) {
		global $group;
 
		// œwÅ 1 4œ ‘Ö;;
		if($group[use_icon]==0) {
			if($data[ismember]) { 
				if($data[islevel]==2) $face_image="<img src=images/admin2_face.gif border=0 align=absmiddle>";
				elseif($data[islevel]==1) $face_image="<img src=images/admin1_face.gif border=0 align=absmiddle>";
				else {
					if($group[icon]) $face_image="<img src=icon/$group[icon] border=0 align=absmiddle>";
					else $face_image="<img src=images/member_face.gif border=0 align=absmiddle>";
				}
			} 
			else $face_image="<img src=images/blank_face.gif border=0 align=absmiddle> ";
		}
 
		$temp_name = get_private_icon($data[ismember], "1");
		if($temp_name) $face_image="<img src='$temp_name' border=0 align=absmiddle>";
	
		if($group[use_icon]<2&&$data[ismember]) $face_image .= "<b>";
 
		//if($data[ismember]&&$data[parent]) $face_image="<b>";
		//elseif($data[parent]) $face_image="";
	
		return $face_image;
	}
 
 
	// j[× flà£Ö ¹ü| aŸ
	function check_board_master($member, $board_num) {
		$temp = split(",",$member[board_name]);
		for($i=0;$i<count($temp);$i++) {
			$t = trim($temp[$i]);
			if($t&&$t==$board_num) return 1;
		}
		return 0;
	}
 
	//  þf ™&‚ ‘¥? aŸ;;;;
	function head($body="",$scriptfile="") {
 
		global $group, $setup, $dir,$member, $PHP_SELF, $id, $_head_executived, $HTTP_COOKIE_VARS, $width;
 
		if($_head_executived) return;
		$_head_executived = true;
 
		$f = @fopen("license.txt","r");
		$license = @fread($f,filesize("license.txt"));
		@fclose($f);
 
		print "<!--\n".$license."\n-->\n";
	
		if(!eregi("member_",$PHP_SELF)) $stylefile="skin/$setup[skinname]/style.css"; else $stylefile="style.css";
 
		if($setup[use_formmail]) {
			$f = fopen("script/script_zbLayer.php","r");
			$zbLayerScript = fread($f, filesize("script/script_zbLayer.php"));
			fclose($f);
		}
		
		// html [ÛaŸ N˜
		if($setup[skinname]) {
			?>
<html> 
<head>
	<title><?=$setup[title]?></title>
	<meta http-equiv=Content-Type content=text/html; charset=BIG5>
	<link rel=StyleSheet HREF=<?=$stylefile?> type=text/css title=style>
	<?if($setup[use_formmail]) echo $zbLayerScript;?>
	<?if($scriptfile) include "script/".$scriptfile;?>
</head>
<body topmargin='0'  leftmargin='0' marginwidth='0' marginheight='0' <?=$body?><?
 
			if($setup[bg_color]) echo " bgcolor=".$setup[bg_color]." ";
			if($setup[bg_image]) echo " background=".$setup[bg_image]." ";
 
			?>>
			<?
			if($group[header_url]) { $g_head = "layout/config/layout/".$group[header_url]."/setup.php"; }
			if($setup[header_url]) { $s_head = "layout/config/layout/".$setup[header_url]."/setup.php"; }
			if(is_file("$g_head")) { include $g_head; }elseif(is_file("$s_head")) { include $s_head; }
			if($miso_layout == "ok") include $_zb_path."layout/head.php";
			if($group[header_url]) { @include $group[header_url]; }
			if($setup[header_url]) { @include $setup[header_url]; }
			if($group[header]) echo stripslashes($group[header]);
			if($setup[header]) echo stripslashes($setup[header]);
			?>
			<table border=0 cellspacing=0 cellpadding=0 width=<?=$width?> height=1 style="table-layout:fixed;"><col width=100%></col><tr><td><img src=images/t.gif border=0 width=98% height=1 name=zb_get_table_width><br><img src=images/t.gif border=0 name=zb_target_resize width=1 height=1></td></tr></table>
			<?
		} else {
 
			?>
<html>
<head>
	<meta http-equiv=Content-Type content=text/html; charset=BIG5>
	<link rel=StyleSheet HREF=style.css type=text/css title=style>
	<?=$script?>
</head>
<body topmargin='0'  leftmargin='0' marginwidth='0' marginheight='0' <?=$body?>>
			<?
				if($group[header_url]) { @include $group[header_url]; }
				if($group[header]) echo stripslashes($group[header]);
		}
 
	}
 
 
 
	// W* aŸ N˜
	function foot() {
 
		global $width, $group, $setup, $_startTime , $_queryTime , $_foot_executived, $_skinTime, $_sessionStart, $_sessionEnd, $_nowConnectStart, $_nowConnectEnd, $_dbTime, $_listCheckTime, $_zbResizeCheck;
 
		if($_foot_executived) return;
		$_foot_executived = true;
 
		$maker_file=@file("skin/$setup[skinname]/maker.txt");
		if($maker_file[0]) $maker="/ skin by $maker_file[0]";
		else $maker = "";
 
		if($setup[skinname]) {
			?>
 
			<table border=0 cellpadding=0 cellspacing=0 height=20 width=<?=$width?>>
			<tr>
				<td align=right style=font-family:tahoma,°0Ô;font-size:8pt;line-height:150%;letter-spacing:0px>
					<font style=font-size:7pt>Copyright 1999-<?=date("Y")?></font> <a href=http://www.zeroboard.com target=_blank onfocus=blur()><font style=font-family:tahoma,°0Ô;font-size:8pt;>Zeroboard</a> <?=$maker?>
				</td>   
			</tr>
			</table>
 
			<?
			if($_zbResizeCheck) {
			?>
			<!-- œÖ lœT‚ *…® @l| aŸ -->
			<script>
				function zb_img_check(){
					var zb_main_table_width = document.zb_get_table_width.width;
					var zb_target_resize_num = document.zb_target_resize.length;
					for(i=0;i<zb_target_resize_num;i++){ 
						if(document.zb_target_resize[i].width > zb_main_table_width) {
							document.zb_target_resize[i].width = zb_main_table_width;
						}
					}
				}
				window.onload = zb_img_check;
			</script>
 
			<?
			}
 
			if($setup[footer]) echo stripslashes($setup[footer]);
			if($group[footer]) echo stripslashes($group[footer]);
			if($setup[footer_url]) { @include $setup[footer_url]; }
			if($group[footer_url]) { @include $group[footer_url]; }
			if($group[header_url]) { $g_head = "layout/config/layout/".$group[header_url]."/setup.php"; }
			if($setup[header_url]) { $s_head = "layout/config/layout/".$setup[header_url]."/setup.php"; }
			if(is_file("$g_head")) { include $g_head; }elseif(is_file("$s_head")) { include $s_head; }
			if($miso_layout == "ok") include $_zb_path."layout/foot.php";
			?>
 
</body>
</html>
			<?
			
		} else {
 
			if($group[footer]) echo stripslashes($group[footer]);
			if($group[footer_url]) { @include $group[footer_url]; }
 
			?>
			</body>
			</html>
			<?
		}
 
		$_phpExcutedTime = (getmicrotime()-$_startTime)-($_sessionEnd-$_sessionStart)-($_nowConnectEnd-$_nowConnectStart)-$_dbTime-$_skinTime;
		// [d N˜
		echo "\n\n<!--"; 
		if($_sessionStart&&$_sessionEnd)  		echo"\n Session Excuted  : ".sprintf("%0.4f",$_sessionEnd-$_sessionStart);
		if($_nowConnectStart&&$_nowConnectEnd) 	echo"\n Connect Checked  : ".sprintf("%0.4f",$_nowConnectEnd-$_nowConnectStart);
		if($_dbTime)  							echo"\n Query Excuted  : ".sprintf("%0.3f",$_dbTime);
		if($_phpExcutedTime)  					echo"\n PHP Excuted  : ".sprintf("%0.3f",$_phpExcutedTime);
		if($_listCheckTime) 					echo"\n Check Lists : ".sprintf("%0.3f",$_listCheckTime);
		if($_skinTime) 							echo"\n Skins Excuted  : ".sprintf("%0.3f",$_skinTime);
   		if($_startTime) 						echo"\n Total Excuted Time : ".sprintf("%0.3f",getmicrotime()-$_startTime);
		echo "\n-->\n";
	}
 
 
	// zbLayer N˜
	function check_zbLayer($data) {
		global $zbLayer, $setup, $member, $is_admin, $id, $_zbCheckNum;
		if($setup[use_formmail]) {
			if(!$_zbCheckNum) $_zbCheckNum=0;
			$data[name]=stripslashes($data[name]);
			$data[name]=urlencode($data[name]);
			//$data[name]=str_replace("\"","",$data[name]);
			//$data[name]=str_replace("'","\'",$data[name]);
			//$data[name]=str_replace(" ","",$data[name]);
 
			if($data[homepage]){
				$data[homepage]=str_replace("http://","",stripslashes($data[homepage]));
				//$data[homepage]=str_replace("\"","",$data[homepage]);
				//$data[homepage]=str_replace("'","",$data[homepage]);
				//$data[homepage]=str_replace(" ","",$data[homepage]);
				$data[homepage]=urlencode($data[homepage]);
				$data[homepage]="http://".$data[homepage];
			}
 
			$data[email]=base64_encode($data[email]);
 
			$_zbCheckNum++;
			$_zbCount=1;
 
			if(($member[is_admin]==1||$member[is_admin]==2)&&$data[ismember]) {
				$traceID = $data[ismember];
				$traceType="t";
				$isAdmin=1;
			} elseif(($member[is_admin]==1||$member[is_admin]==2)&&!$data[ismember]) {
				$traceID = $data[name];
				$traceType="tn";
				$isAdmin=1;
			}
 
			if($member[no]) $isMember = 1;
 
			if($data[ismember]<1) $data[ismember]="";
 
			$zbLayer = $zbLayer."\nprint_ZBlayer('zbLayer$_zbCheckNum', '$data[homepage]', '$data[email]', '$data[ismember]', '$id', '$data[name]', '$traceID', '$traceType', '$isAdmin', '$isMember');";
		}   
		return $_zbCount;
	}
	
 
	// ] m®Ö N˜
	function error($message, $url="") {
		global $setup, $connect, $dir, $config_dir;
 
		$dir="skin/".$setup[skinname];
 
		if($url=="window.close") {
			$message=str_replace("<br>","\\n",$message);
			$message=str_replace("\"","\\\"",$message);
			?>
			<script>
				alert("<?=$message?>");
				window.close();
			</script>
			<?
		} else {
 
			head();
 
			if($setup[skinname]) {
				include "skin/$setup[skinname]/error.php";
			} else {
				include $config_dir."error.php";
			}
 
			foot();
 
		}
 
		if($connect) @mysql_close($connect);
 
		exit;
	}
 
 
	// j[× ²‘Ê —k%
	function get_table_attrib($id) {
 
		global $connect, $admin_table;
 
		$data=mysql_fetch_array(mysql_query("select * from $admin_table where name='$id'",$connect));
 
		if($data[table_width]<=100) $data[table_width]=$data[table_width]."%"; 
 
		// 3Z IP‚ >y? fߣI, DB ò3Ê t|f *…® œÖ "v ¨ ~2N ò3|y ¨
		if(!$data[use_showip]) $data[use_showip] = 1;
		$data[grant_imagebox] = $data[use_showip];
 
		return $data;
	}
 
 
	// j[×Ö ©¸  
	function istable($str, $dbname='') {
		global $config_dir;
		if(!$dbname) {
			$f=@file($config_dir."config.php") or Error("config.php
X(<br>ËH-šÇ™«","install.php");
			for($i=1;$i<=4;$i++) $f[$i]=str_replace("\n","",$f[$i]);
			$dbname=$f[4];
		}
 
		$result = mysql_list_tables($dbname) or error(mysql_error(),"");
 
		$i=0;
 
		while ($i < mysql_num_rows($result)) {
			if($str==mysql_tablename ($result, $i)) return 1;
			$i++;
		}
		return 0;
	}
 
 
	// £ß 4œtæ ?k 4œt lv¾‚  –|y 4œt °c  ;à£Ö 
	function check_blockip() {
		global $setup;
		$avoid_ip=explode(",",$setup[avoid_ip]);
		$count = count($avoid_ip);
		for($i=0;$i<$count;$i++) {
			if(!isblank($avoid_ip[$i])&&eregi($avoid_ip[$i],$REMOTE_ADDR)) Error("`„IP«b(,Ù");
		}
	}
 
 
	// ~à± ¹ü
	function getNowConnector($filename,$div) {
		global $_zbDefaultSetup;
		$_str = trim(zReadFile($filename));
		$num = 0;
		if($_str) {
			$_str = str_replace("<?/*","",$_str);
			$_str = str_replace("*/?>","",$_str);
			$_connector = explode(":",$_str);
			$_sizeConnector = count($_connector);
			$_nowtime = date("YmdHi");
			unset($_realNowConnector);
			if($_sizeConnector) {
				for($i=0;$i<$_sizeConnector;$i++) {
					$_time = substr($_connector[$i],0,12);
					$_div = substr($_connector[$i],12);
					if($_time+$_zbDefaultSetup[nowconnect_time]>=$_nowtime&&$_div!=$div) {
						$_realNowConnector.=$_time.$_div.":";
						$num++;
					}
				}
			}
		}
		$_realNowConnector.=$_nowtime.$div;
		//check_fileislocked($filename);
		zWriteFile($filename, "<?/*".$_realNowConnector."*/?>");
		return $num;
	}
 
	// ~à± ˜|f
	function getNowConnector_num($filename, $FLAG=FALSE) {
		global $_zbDefaultSetup;
		$_str = trim(zReadFile($filename));
		$num = 0;
		if($_str) {
			$_str = str_replace("<?/*","",$_str);
			$_str = str_replace("*/?>","",$_str);
			$_connector = explode(":",$_str);
			$_sizeConnector = count($_connector);
			$_nowtime = date("YmdHi");
			unset($_realNowConnector);
			if($_sizeConnector) {
				for($i=0;$i<$_sizeConnector;$i++) {
					$_time = substr($_connector[$i],0,12);
					$_div = substr($_connector[$i],12);
					if($_time+$_zbDefaultSetup[nowconnect_time]>=$_nowtime) {
						$_realNowConnector.=$_time.$_div.":";
						$num++;
					}
				}
			}
		}
		if($FLAG) {
			//check_fileislocked($filename);
			zWriteFile($filename, "<?/*".$_realNowConnector."*/?>");
		}
		return $num;
	}
 
 
	// ¯N> àÕ Nœ£ ®®Øœ Ö ×=…® 2Ê …! ØÊ l
	function getZBSessionID() {
		global $HTTP_COOKIE_VARS, $_zb_path, $_zbDefaultSetup;
 
		$zbSessionID = $HTTP_COOKIE_VARS[ZBSESSIONID];
 
		if(!$zbSessionID) return "";
		$str = zReadFile($_zb_path.$_zbDefaultSetup[session_path]."/zbSessionID_".$zbSessionID.".php");
 
		if(!$str) {
			@setcookie("ZBSESSIONID", "", time()+60*60*24*365, "/");
			return "";
		}
 
		$str = explode("\n",$str);
 
		$data[no] = trim($str[1]);
		$data[time] = trim($str[2]);
 
		$newZBSessionID = md5($data[no]."-^A-".$data[time]);
 
		if($newZBSessionID != $zbSessionID) {
			@setcookie("ZBSESSIONID", "", time()+60*60*24*365, "/");
			return "";
		}
 
		if(!$_zb_path) {
			z_unlink($_zb_path.$_zbDefaultSetup[session_path]."/zbSessionID_".$zbSessionID.".php");
			makeZBSessionID($data[no]);
		}
 
		return $data;
	}
 
 
	// ¯N> àÕ Nœ£ ®®ØÊ \ ±
	function makeZBSessionID($no) {
		global $HTTP_COOKIE_VARS, $_zb_path, $_zbDefaultSetup;
 
		$zbSessionID = md5($no."-^A-".time());
 
		$newStr = "<?/*\n$no\n".time()."\n*/?>";
 
		zWriteFile($_zb_path.$_zbDefaultSetup[session_path]."/zbSessionID_".$zbSessionID.".php", $newStr);
 
		@setcookie("ZBSESSIONID", $zbSessionID, time()+60*60*24*365, "/");
	}
 
 
	// ¯N> àÕ Nœ£ ®®Ø Ôf[H ±
	function destroyZBSessionID($no) {
		global $HTTP_COOKIE_VARS, $_zb_path, $_zbDefaultSetup;
		$zbSessionID = $HTTP_COOKIE_VARS[ZBSESSIONID];
		z_unlink($_zb_path.$_zbDefaultSetup[session_path]."/zbSessionID_".$zbSessionID.".php");
		@setcookie("ZBSESSIONID", "", time()+60*60*24*365, "/");
	}
 
	// ¯N>Ö fD ²‘ Ô~Ê —kƒ ±
	function getDefaultSetup() {
		global $_zb_path;
		$data = zReadFile($_zb_path."setup.php");
		$data = str_replace("<?/*","",$data);	
		$data = str_replace("*/?>","",$data);	
		$data = explode("\n",$data);
		$_c = count($data);
		unset($defaultSetup);
		for($i=0;$i<$_c;$i++) {
			if(!ereg(";",$data[$i])&&strlen(trim($data[$i]))) {
				$tmpStr = explode("=",$data[$i]);
				$name = trim($tmpStr[0]);
				$value = trim($tmpStr[1]);
				$defaultSetup[$name]=$value;
			}
		}
		if(!$defaultSetup[url]) $defaultSetup[url] = $HTTP_HOST;
		if(!$defaultSetup[sitename]) $defaultSetup[sitename] = $HTTP_HOST;
		if(!$defaultSetup[session_path]) $defaultSetup[session_path] = "data/__zbSessionTMP";
		if(!$defaultSetup[session_view_size]) $defaultSetup[session_view_size] = 512;
		if(!$defaultSetup[session_vote_size]) $defaultSetup[session_vote_size] = 256;
		if(!$defaultSetup[login_time]) $defaultSetup[login_time] = 60*30;
		if(!$defaultSetup[nowconnect_enable]) $defaultSetup[nowconnect_enable] = "true";
		if(!$defaultSetup[nowconnect_refresh_time]) $defaultSetup[nowconnect_refresh_time] = 60*3;
		if(!$defaultSetup[nowconnect_time]) $defaultSetup[nowconnect_tim] = 60*5;
		if(!$defaultSetup[enable_hangul_id]) $defaultSetup[enable_hangul_id] = "false";
		if(!$defaultSetup[check_email]) $defaultSetup[check_email] = "true";
		if(!$defaultSetup[memo_limit_time]) $defaultSetup[memo_limit_time] = 7;
		$defaultSetup[memo_limit_time] = 60 * 60 * 24 * $defaultSetup[memo_limit_time];
		 
		return $defaultSetup;
	}
 
 
	/******************************************************************************
 	 * ~i ±
 	 *****************************************************************************/
	// ´åàî 3¦ 1Ê l
	function isblank($str) {
		$temp=str_replace("[","",$str);
		$temp=str_replace("\n","",$temp);
		$temp=strip_tags($temp);
		$temp=str_replace("&nbsp;","",$temp);
		$temp=str_replace(" ","",$temp);
		if(eregi("[^[:space:]]",$temp)) return 0;
		return 1;
	}
 
 
	// ‹à~ 3¦ 1Ê l
	function isnum($str) {
		if(eregi("[^0-9]",$str)) return 0;
		return 1;
	}
 
 
	// ‹à, Yåà ~3¦ 1Ê l
	function isalNum($str) {
		if(eregi("[^0-9a-zA-Z\_]",$str)) return 0;
		return 1;
	}
 
 
	// HTML Tag‚ ¯j| ±
	function del_html( $str ) {
		$str = str_replace( ">", "&gt;",$str );
		$str = str_replace( "<", "&lt;",$str );
		return $str;
	}
 
 
	// ?ÔYÓí 
	function check_jumin($jumin) { 
		$weight = '234567892345'; // àl± weight Ö‘ 
		$len = strlen($jumin); 
		$sum = 0; 
 
		if ($len <> 13) return false;
 
		for ($i = 0; $i < 12; $i++) { 
			$sum = $sum + (substr($jumin,$i,1)*substr($weight,$i,1)); 
		} 
 
		$rst = $sum%11; 
		$result = 11 - $rst; 
 
		if ($result == 10) $result = 0;
		else if ($result == 11) $result = 1;
 
		$ju13 = substr($jumin,12,1); 
 
		if ($result <> $ju13) return false;
		return true; 
	} 
 
 
	// E-mail ?![ ¢%GÖ 
	function ismail( $str ) {
		if( eregi("([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)", $str) ) return $str;
		else return ''; 
	}
 
	// E-mail Ö MX‚ |y ¯ Dß| m~£Ö 
	function mail_mx_check($email) {
		if(!ismail($email)) return false;
		list($user, $host) = explode("@", $email);
		if (checkdnsrr($host, "MX") or checkdnsrr($host, "A")) return true;
		else return false;
	}
 
 
	// òôœÖ ?![ ¢%GÖ 
	function isHomepage( $str ) {
		if(eregi("^http://([a-z0-9\_\-\./~@?=&amp;-\#{5,}]+)", $str)) return $str;
		else return '';
	}
 
 
	// URL, MailÊ àÕ2N ¹ü|y mü\ß
	function autolink($str) {
		// URL ‚ù
		$homepage_pattern = "/([^\"\'\=\>])(mms|http|HTTP|ftp|FTP|telnet|TELNET)\:\/\/(.[^ \n\<\"\']+)/";
		$str = preg_replace($homepage_pattern,"\\1<a href=\\2://\\3 target=_blank>\\2://\\3</a>", " ".$str);
 
		// m~ ‚ù
		$email_pattern = "/([ \n]+)([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)/";
		$str = preg_replace($email_pattern,"\\1<a onfocus=blur() href=javascript:void(window.open('sendmail.php?to=\\2@\\3','_blank','left=0,top=0,width=206,height=300'))>\\2@\\3</a>", " ".$str);
 
		return $str;
	}
 
 
	// Ô~ œT‚ kb, mb zk® òù…® l
	function getfilesize($size) {
		if(!$size) return "0 Byte";
		if($size<1024) { 
			return ($size." Byte");
		} elseif($size >1024 && $size< 1024 *1024)  {
			return sprintf("%0.1f KB",$size / 1024);
		}
		else return sprintf("%0.2f MB",$size / (1024*1024));
	}
 
 
	// åàî ’f (œ;Ö œ~} ... N R[)
	function cut_str($msg,$cut_size) {
		if($cut_size<=0) return $msg;
		if(ereg("\[re\]",$msg)) $cut_size=$cut_size+4;
		for($i=0;$i<$cut_size;$i++) if(ord($msg[$i])>127) $han++; else $eng++;
		$cut_size=$cut_size+(int)$han*0.6;
		$point=1;
		for ($i=0;$i<strlen($msg);$i++) {
			if ($point>$cut_size) return $pointtmp."...";
			if (ord($msg[$i])<=127) {
				$pointtmp.= $msg[$i];
				if ($point%$cut_size==0) return $pointtmp."..."; 
			} else {
				if ($point%$cut_size==0) return $pointtmp."...";
				$pointtmp.=$msg[$i].$msg[++$i];
				$point++;
			}
			$point++;
		}
		return $pointtmp;
	}
 
 
	// ôœÖ œÕ vüc¾
	function movepage($url) {
		global $connect;
		echo"<meta http-equiv=\"refresh\" content=\"0; url=$url\">";
		if($connect) @mysql_close($connect);
		exit;
	}
 
	// input ³ textareaÖ œT‚ ˜Yæ Ûv~} ˜Ÿ|y l
	function size($size) {
		global $browser;
		if(!$browser) return " size=".($size*0.6)." ";
		else return " size=$size ";
	}
 
	function size2($size) {
		global $browser;
		if(!$browser) return " cols=".($size*0.6)." ";
		else return " cols=$size ";
	}
 
 
	// m~ > ±
	function zb_sendmail($type, $to, $to_name, $from, $from_name, $subject, $comment, $cc="", $bcc="") {
		$recipient = "$to_name <$to>";
 
		if($type==1) $comment = nl2br($comment);
 
		$headers = "From: $from_name <$from>\n";
		$headers .= "X-Sender: <$from>\n";
		$headers .= "X-Mailer: PHP ".phpversion()."\n";
		$headers .= "X-Priority: 1\n";
		$headers .= "Return-Path: <$from>\n";
 
		if(!$type) $headers .= "Content-Type: text/plain; ";
		else $headers .= "Content-Type: text/html; ";
		$headers .= "charset=BIG5\n";
 
		if($cc)  $headers .= "cc: $cc\n";
		if($bcc)  $headers .= "bcc: $bcc";
 
		$comment = stripslashes($comment);
		$comment = str_replace("\n\r","\n", $comment);
 
		return mail($recipient , $subject , $comment , $headers);
 
	}
 
	// Ö‘9 äÓ\lÖ Ô~ ‘>‚ ˜
	function get_dirinfo($path) {
 
		$handle=@opendir($path);
		while($info = readdir($handle)) {
			if($info != "." && $info != "..") {
				$dir[] = $info;
			}
		}
		closedir($handle);
		return $dir;
	}
 
	// Ô~Ê 	¯| ±
	function z_unlink($filename) {
		@chmod($filename,0777);
		$handle = @unlink($filename);
		if(@file_exists($filename)) {
			@chmod($filename,0775);
			$handle=@unlink($filename);
		}
		return $handle;
	}
 
	// Ö‘9 Ô~Ö ¨Ê —k%
	function zReadFile($filename) {
		if(!file_exists($filename)) return '';
 
		$f = fopen($filename,"r");
		$str = fread($f, filesize($filename));
		fclose($f);
 
		return $str;
	}
 
	// Ö‘9 Ô~ ?k Iœk‚ j
	function zWriteFile($filename, $str) {
		$f = fopen($filename,"w");
		$lock=flock($f,2);
		if($lock) {
			fwrite($f,$str);
		}
		flock($f,3);
		fclose($f);
	}
 
	// Ö‘9 Ô~œ Lockingž£Ö 
	function check_fileislocked($filename) {
		$f=@fopen($filename,w);
		$count = 0;
		$break = true;
		while(!@flock($f,2)) {
			$count++;
			if($count>10) {
				$break = false;
				break;
			}
		}
		if($break!=false) @flock($f,3);
		@fclose($f);
	}
 
	// Vù³2N äÓ\l‚ 	¯
	function zRmDir($path) { 
		$directory = dir($path); 
		while($entry = $directory->read()) { 
			if ($entry != "." && $entry != "..") { 
				if (Is_Dir($path."/".$entry)) { 
					zRmDir($path."/".$entry); 
				} else { 
					@UnLink ($path."/".$entry); 
				} 
			} 
		} 
		$directory->close(); 
		@RmDir($path); 
	}
?>

Open in new window

0
Chiehkai
Asked:
Chiehkai
2 Solutions
 
hieloCommented:
change:

<?
/******************************************************************************
 * Zeroboard library 
 *
 * FÖ^ ±?~à : 2006. 3. 15
 * ? Ô~.Ö Å. ±. 3|[. N .¨|w+ Lòû.
 *
 * by zero (zero@nzeo.com)
 *
 ******************************************************************************/
 
    // W3C P3P XÒ²?
    @header ("P3P : CP=\"ALL CURa ADMa DEVa TAIa OUR BUS IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC OTC\"");
 
	// £ß WÒ
	$zb_version = "4.1 pl8";
 
	/*******************************************************************************
 	 * .] l.Ó ²?A register_globals_on~} ò± ß ?Ö
 	 ******************************************************************************/
 	@error_reporting(E_ALL ^ E_NOTICE);
        foreach($_GET as $key=>$val) $$key = del_html($val);
	@extract($_POST); 
	@extract($_SERVER); 
	@extract($_ENV);
 
        $page = (int)$page;
 
	$temp_filename=realpath(__FILE__);
	if($temp_filename) $config_dir=eregi_replace("lib.php","",$temp_filename);
	else $config_dir="";
 
	/*******************************************************************************
 	 * fD ò± þf÷. (phpÖ ?ß}Ö JÎ ?ß }å.;; ))+)
 	 ******************************************************************************/
	unset($member);
	unset($group);
	unset($setup);
 
	/*******************************************************************************
 	 * include Nw.Ö? ..
 	 ******************************************************************************/
	if(defined("_zb_lib_included")) return;
    define("_zb_lib_included",true);
 
	$_startTime=getmicrotime();
 
	/*******************************************************************************
 	 * fD ²? Ô~Ê ?à
 	 ******************************************************************************/
 	$_zbDefaultSetup = getDefaultSetup();
 
	/*******************************************************************************
 	 * install ô?Ö[ 4Ë 3¦
 	 ******************************************************************************/
	if(!eregi("install",$PHP_SELF)&&file_exists($_zb_path."config.php")) {
 
 	 	//®® @l (®®Î 3~Õð ¸	|j ²?)
		if(!is_dir($_zb_path.$_zbDefaultSetup[session_path])) {
			mkdir($_zb_path.$_zbDefaultSetup[session_path], 0777);
			chmod($_zb_path.$_zbDefaultSetup[session_path], 0777);
		}
 
		// Data, Icon, ®®äÓ\lÖ Yf ~? HûÊ .] @l
		if(!is_writable($_zb_path."data")) error("!Õ(dataÇ?>ëeÇ?.<br>(Zeroboard.Ëf?dataÇ?>?ëe
P.");
		if(!is_writable($_zb_path."icon")) error("!Õ(iconÇ?>ëeÇ?.<br>(Zeroboard.Ëf?iconÇ?>?ëe
P.");
		if(!is_writable($_zb_path.$_zbDefaultSetup[session_path])) error("!Õ(sessionÇ?>(".$_zb_path.$_zbDefaultSetup[session_path].")ëeÇ?.<br>(Zeroboard.Ëf?sessionÇ?>?ëe
P.");
 
		$_sessionStart = getmicrotime();
		@session_save_path($_zb_path.$_zbDefaultSetup[session_path]);
		@session_cache_limiter('nocache, must_revalidate');
 
		session_set_cookie_params(0,"/");
 
		// ®® ò±Ö ÔY
		@session_start();
		// added by sbluo start
		$this->sid = session_id();
		$sessionid = $this->sid;
		// added by sbluo end
 
		// ;.± [ 512byte?, qR ®®ò±[ 256byte? iÊ[ l¢ (C£®W? ?¨[.. ;Î & ú¥+ >)
		if(strlen($_SESSION[zb_hit])>$_zbDefaultSetup[session_view_size]) {
			$zb_hit='';
			session_register("zb_hit");
		}
		if(strlen($_SESSION[zb_vote])>$_zbDefaultSetup[session_vote_size]) {
			$zb_vote='';
			session_register("zb_vote");
		}
 
		// àÕ N?£~} ¯ N 9 àÕ N?££Ö ¹ü|. a?
		unset($autoLoginData);
		$autoLoginData = getZBSessionID();
		if($autoLoginData[no]) {
			$zb_logged_no=$autoLoginData[no];
			// added by sbluo start, 01142005
			$zb_logged_ip=$sessionid;
			// added by sbluo end, 01142005
			$zb_logged_time=time();
			session_register("zb_logged_no");
			session_register("zb_logged_ip");
			session_register("zb_logged_time");
			$_SESSION["zb_logged_no"] = $zb_logged_no;
 
		// ®® ØÊ ¹ü|y N?£Ê @l
		} elseif($_SESSION["zb_logged_no"]) {
 
			// N?£ [d? Ö?9 [dÊ iwjí N?£ 4?t[ £ß .¨àÖ 4?tæ û? 3¦ N?4? [=
			// added by sbluo start, 01142005
			if(time()-$_SESSION["zb_logged_time"]>$_zbDefaultSetup["login_time"]||$_SESSION["zb_logged_ip"]!=$sessionid) {
			// added by sbluo end, 01142005
 
				$zb_logged_no="";
				$zb_logged_time="";
				$zb_logged_ip="";
				session_register("zb_logged_no");
				session_register("zb_logged_ip");
				session_register("zb_logged_time");
				session_destroy();
 
			// ¸	 3¦ N?£ [dÊ û[ ²?
			} else {
				// 4.0x ¨ ®® @l
				$zb_logged_time=time();
				session_register("zb_logged_time");
			}
 
		} 
		$_sessionEnd = getmicrotime();
 
		// £ß ~.àÖ I?k? ¹ü|y Ô~N êð (.3,  .32N ???® êð)
		$_nowConnectStart = getmicrotime();
		if($_zbDefaultSetup[nowconnect_enable]=="true") {
			$_zb_now_check_intervalTime = time()-$_SESSION["zb_last_connect_check"];
 
			if(!$_SESSION["zb_last_connect_check"]||$_zb_now_check_intervalTime>$_zbDefaultSetup[nowconnect_refresh_time]) {
 
				// 4.0x ¨ ®® @l
				$zb_last_connect_check = time();
				session_register("zb_last_connect_check");
 
				if($_SESSION["zb_logged_no"]) {
					$total_member_connect = $total_connect = getNowConnector($_zb_path."data/now_member_connect.php",$_SESSION[zb_logged_no]);
					$total_guest_connect = getNowConnector_num($_zb_path."data/now_connect.php", TRUE);
				} else {
					$total_member_connect = $total_connect = getNowConnector_num($_zb_path."data/now_member_connect.php", TRUE);
					$total_guest_connect = getNowConnector($_zb_path."data/now_connect.php",$REMOTE_ADDR);
				}
			} else {
				$total_member_connect = $total_connect = getNowConnector_num($_zb_path."data/now_member_connect.php",FALSE);
				$total_guest_connect = getNowConnector_num($_zb_path."data/now_connect.php",FALSE);
			}
 
		}
 
	}
 
	$_nowConnectEnd = getmicrotime();
 
	// config.php Ô~Ö *?? ?;;
	$temp_filename=realpath(__FILE__);
	if($temp_filename) $config_dir=eregi_replace("lib.php","",$temp_filename);
	else $config_dir="";
 
 
	// Ûvæ ?v¨?n~} @l
	if(eregi("msie",$HTTP_USER_AGENT)) $browser="1"; else $browser="0";
 
 
	// DB[ ²?? Nw.Ö? ..
	if(!file_exists($config_dir."config.php")&&!eregi("install",$PHP_SELF)) {
 		echo"<meta http-equiv=\"refresh\" content=\"0; url=install.php\">";
 		exit;
	}
 
 
	// flà ??°A .3fl ??°Ö ?wÊ .l ò±N ?Ö
	$member_table = "zetyx_member_table";  // .3ßÖ I?k[ ßk .. .~³£ ??°
	$group_table = "zetyx_group_table";   // ?\??°
	$admin_table="zetyx_admin_table";     // j[×Ö flà ??°
 
	$send_memo_table ="zetyx_send_memo";
	$get_memo_table ="zetyx_get_memo";
 
	$t_division="zetyx_division"; // Division ??°
	$t_board = "zetyx_board"; // m£ ??°
	$t_comment ="zetyx_board_comment"; // Àn¾??°
	$t_category ="zetyx_board_category"; // .?.l ??°
 
 
	// F?üN k\ ?
	function getmicrotime() {
    	$microtimestmp = split(" ",microtime());
    	return $microtimestmp[0]+$microtimestmp[1];
	}
 
 
	/******************************************************************************
 	* Division f¼ ±
 	*****************************************************************************/
	// ª¹ division ?
	function total_division() {
 		global $connect, $t_division, $id;
 		$temp=mysql_fetch_array(mysql_query("select max(division) from $t_division"."_$id"));
 		return $temp[0];
	}
 
	// /Ë~} ?! divisionÖ num Ø ¸[
	function plus_division($division) {
		global $connect, $t_division, $id;
		mysql_query("update $t_division"."_$id set num=num+1 where division='$division'") or error(mysql_error);
	}
 
	// 	¯|jí bÖËÊ ~iËN af. ÔÖ division numØ ò÷[ ?! divisionÖ numØ ¬![=
	function minus_division($division) {
		global $connect, $t_division, $id;
		mysql_query("update $t_division"."_$id set num=num-1 where division='$division'") or error(mysql_error);
	}
 
 
	// .XËYf~} F¬ divisionÖ num Ø ¸[
	function add_division($board_name="") {
		global $connect, $t_division, $id, $t_board;
		if($board_name) $board_id=$board_name;
		else $board_id=$id;
		$temp=mysql_fetch_array(mysql_query("select num from $t_division"."_$board_id order by division desc limit 1"));
 
		// £ß divisionÖ numØ? f}Ø~}. division +1 ??;
		if($temp[0]>=5000) {
			$temp=mysql_fetch_array(mysql_query("select max(division) from $t_division"."_$board_id"));
			$max_division=$temp[0]+1;
			$temp=mysql_fetch_array(mysql_query("select max(division) from $t_division"."_$board_id where num>0 and division!='$max_division'"));
			if(!$temp[0]) $second_division=0; else $second_division=$temp[0];
			$temp=mysql_fetch_array(mysql_query("select count(*) from $t_board"."_$board_id where (division='$max_division' or division='$second_division') and headnum<=-2000000000"));
			if($temp[0]>0) {
				mysql_query("update $t_board"."_$board_id set division='$max_division' where (division='$max_division' or division='$second_division') and  headnum<='-2000000000'") or error(mysql_error());
				mysql_query("update $t_division"."_$board_id set num=num-$temp[0] where division=$max_division-1") or error(mysql_error());
			}
			$num=$temp[0]+1;
			mysql_query("insert into $t_division"."_$board_id (division,num) values ('$max_division','$num')");
			return $max_division;
		} else {
 		// £ß division? f}ØC>û ÛÊ}~
			$temp=mysql_fetch_array(mysql_query("select max(division) from $t_division"."_$board_id"));
			$division=$temp[0];
			mysql_query("update $t_division"."_$board_id set num=num+1 where division='$division'");
			return $division;
		}
	}
 
 
	/******************************************************************************
 	* N?£? Nk ..Ö? ..|y N?£Nk.2Ê ?! .3Ö ?>? êð
 	*****************************************************************************/
	function member_info() {
 
		global $_SESSION, $member_table, $REMOTE_ADDR, $member, $connect;
 
		if(defined("_member_info_included")&&$member[no]) return $member;
		define("_member_info_included", true);
 
		if($member[no]) return $member;
 
		if($_SESSION["zb_logged_no"]) {
			$member=mysql_fetch_array(mysql_query("select * from $member_table where no ='".$_SESSION["zb_logged_no"]."'"));
			if(!$member[no]) {
				unset($member);
				$member[level] = 10;
			}
		} else $member[level] = 10;
 
		return $member;
	}
 
 
	function group_info($no) {
		global $group_table;
		$temp=mysql_fetch_array(mysql_query("select * from $group_table where no='$no'"));
		return $temp;
	}
 
 
 
	/******************************************************************************
 	* ¯N>. ª¨ ±
 	*****************************************************************************/
	// MySQL I?k .?v. ~¬
	function dbconn() {
 
		global $connect, $config_dir, $autologin, $HTTP_COOKIE_VARS, $_dbconn_is_included;
 
		if($_dbconn_is_included) return;
		$_dbconn_is_included = true;
 
		$f=@file($config_dir."config.php") or Error("config.php
X(.<br>ËH-?Ç?«.","install.php");
 
		for($i=1;$i<=4;$i++) $f[$i]=trim(str_replace("\n","",$f[$i]));
 
		if(!$connect) $connect = @mysql_connect($f[1],$f[2],$f[3]) or Error("#¥Ç?«BúþOL.");
 
		@mysql_select_db($f[4], $connect) or Error("(?Ç?«úþOL.","");
	
		return $connect;
	}
 
 
	// ËÖ 4?.Ê {4?;;
	function get_icon($data) {
		global $dir;
 
		// Ëy [d ?
		$check_time=((time() + (2 * 60 * 60))-$data[reg_date])/60/60;
 
		// Å. 1. 4?. ?Ö
		if($data[depth]) {
			if($check_time<=12) $icon="<img src=$dir/reply_new_head.gif border=0 align=absmiddle>&nbsp;"; // F¬ Ë~3¦
			else $icon="<img src=$dir/reply_head.gif border=0 align=absmiddle>&nbsp;"; // /Ë~}
		} else {
			if($check_time<=12) $icon="<img src=$dir/new_head.gif border=0 align=absmiddle>&nbsp;"; // F¬ Ë~3¦
			else $icon="<img src=$dir/old_head.gif border=0 align=absmiddle>&nbsp;";          // /Ë? 4Í}
		}
		if($data[headnum]<=-2000000000) $icon="<img src=$dir/notice_head.gif border=0 align=absmiddle>&nbsp;"; // bÖ.?~}
		else if($data[is_secret]==1) $icon="<img src=$dir/secret_head.gif border=0 align=absmiddle alt='??q'>&nbsp;";
		return $icon;
	}
 
 
	// .3 C£.j ?kÖ. 4?.Ê Ê. ±
	// $type : 1 -> ?wÅ. íkí. 4?.
	// $type : 2 -> ?wÊ  .|. 4?.
	function get_private_icon($no, $type) {
		if($type==1) $dir = "icon/private_icon/";
		elseif($type==2) $dir = "icon/private_name/";
 
		if(@file_exists($dir.$no.".gif")) return $dir.$no.".gif";
	}
 
 
	// ?w Å. 1. a? 4?.
	function get_face($data, $check=0) {
		global $group;
 
		// ?wÅ. 1. 4?. ?Ö;;
		if($group[use_icon]==0) {
			if($data[ismember]) { 
				if($data[islevel]==2) $face_image="<img src=images/admin2_face.gif border=0 align=absmiddle>";
				elseif($data[islevel]==1) $face_image="<img src=images/admin1_face.gif border=0 align=absmiddle>";
				else {
					if($group[icon]) $face_image="<img src=icon/$group[icon] border=0 align=absmiddle>";
					else $face_image="<img src=images/member_face.gif border=0 align=absmiddle>";
				}
			} 
			else $face_image="<img src=images/blank_face.gif border=0 align=absmiddle> ";
		}
 
		$temp_name = get_private_icon($data[ismember], "1");
		if($temp_name) $face_image="<img src='$temp_name' border=0 align=absmiddle>";
	
		if($group[use_icon]<2&&$data[ismember]) $face_image .= "<b>";
 
		//if($data[ismember]&&$data[parent]) $face_image="<b>";
		//elseif($data[parent]) $face_image="";
	
		return $face_image;
	}
 
 
	// j[× flà£Ö ¹ü|. a?
	function check_board_master($member, $board_num) {
		$temp = split(",",$member[board_name]);
		for($i=0;$i<count($temp);$i++) {
			$t = trim($temp[$i]);
			if($t&&$t==$board_num) return 1;
		}
		return 0;
	}
 
	//  þf ?&? ?¥?. a?;;;;
	function head($body="",$scriptfile="") {
 
		global $group, $setup, $dir,$member, $PHP_SELF, $id, $_head_executived, $HTTP_COOKIE_VARS, $width;
 
		if($_head_executived) return;
		$_head_executived = true;
 
		$f = @fopen("license.txt","r");
		$license = @fread($f,filesize("license.txt"));
		@fclose($f);
 
		print "<!--\n".$license."\n-->\n";
	
		if(!eregi("member_",$PHP_SELF)) $stylefile="skin/$setup[skinname]/style.css"; else $stylefile="style.css";
 
		if($setup[use_formmail]) {
			$f = fopen("script/script_zbLayer.php","r");
			$zbLayerScript = fread($f, filesize("script/script_zbLayer.php"));
			fclose($f);
		}
		
		// html [Ûa? N?
		if($setup[skinname]) {
			?>
<html> 
<head>
	<title><?=$setup[title]?></title>
	<meta http-equiv=Content-Type content=text/html; charset=BIG5>
	<link rel=StyleSheet HREF=<?=$stylefile?> type=text/css title=style>
	<?if($setup[use_formmail]) echo $zbLayerScript;?>
	<?if($scriptfile) include "script/".$scriptfile;?>
</head>
<body topmargin='0'  leftmargin='0' marginwidth='0' marginheight='0' <?=$body?><?
 
			if($setup[bg_color]) echo " bgcolor=".$setup[bg_color]." ";
			if($setup[bg_image]) echo " background=".$setup[bg_image]." ";
 
			?>>
			<?
			if($group[header_url]) { $g_head = "layout/config/layout/".$group[header_url]."/setup.php"; }
			if($setup[header_url]) { $s_head = "layout/config/layout/".$setup[header_url]."/setup.php"; }
			if(is_file("$g_head")) { include $g_head; }elseif(is_file("$s_head")) { include $s_head; }
			if($miso_layout == "ok") include $_zb_path."layout/head.php";
			if($group[header_url]) { @include $group[header_url]; }
			if($setup[header_url]) { @include $setup[header_url]; }
			if($group[header]) echo stripslashes($group[header]);
			if($setup[header]) echo stripslashes($setup[header]);
			?>
			<table border=0 cellspacing=0 cellpadding=0 width=<?=$width?> height=1 style="table-layout:fixed;"><col width=100%></col><tr><td><img src=images/t.gif border=0 width=98% height=1 name=zb_get_table_width><br><img src=images/t.gif border=0 name=zb_target_resize width=1 height=1></td></tr></table>
			<?
		} else {
 
			?>
<html>
<head>
	<meta http-equiv=Content-Type content=text/html; charset=BIG5>
	<link rel=StyleSheet HREF=style.css type=text/css title=style>
	<?=$script?>
</head>
<body topmargin='0'  leftmargin='0' marginwidth='0' marginheight='0' <?=$body?>>
			<?
				if($group[header_url]) { @include $group[header_url]; }
				if($group[header]) echo stripslashes($group[header]);
		}
 
	}
 
 
 
	// W* a? N?
	function foot() {
 
		global $width, $group, $setup, $_startTime , $_queryTime , $_foot_executived, $_skinTime, $_sessionStart, $_sessionEnd, $_nowConnectStart, $_nowConnectEnd, $_dbTime, $_listCheckTime, $_zbResizeCheck;
 
		if($_foot_executived) return;
		$_foot_executived = true;
 
		$maker_file=@file("skin/$setup[skinname]/maker.txt");
		if($maker_file[0]) $maker="/ skin by $maker_file[0]";
		else $maker = "";
 
		if($setup[skinname]) {
			?>
 
			<table border=0 cellpadding=0 cellspacing=0 height=20 width=<?=$width?>>
			<tr>
				<td align=right style=font-family:tahoma,°0.Ô;font-size:8pt;line-height:150%;letter-spacing:0px>
					<font style=font-size:7pt>Copyright 1999-<?=date("Y")?></font> <a href=http://www.zeroboard.com target=_blank onfocus=blur()><font style=font-family:tahoma,°0.Ô;font-size:8pt;>Zeroboard</a> <?=$maker?>
				</td>   
			</tr>
			</table>
 
			<?
			if($_zbResizeCheck) {
			?>
			<!-- ?.Ö l.?T? *?® @l|. a? -->
			<script>
				function zb_img_check(){
					var zb_main_table_width = document.zb_get_table_width.width;
					var zb_target_resize_num = document.zb_target_resize.length;
					for(i=0;i<zb_target_resize_num;i++){ 
						if(document.zb_target_resize[i].width > zb_main_table_width) {
							document.zb_target_resize[i].width = zb_main_table_width;
						}
					}
				}
				window.onload = zb_img_check;
			</script>
 
			<?
			}
 
			if($setup[footer]) echo stripslashes($setup[footer]);
			if($group[footer]) echo stripslashes($group[footer]);
			if($setup[footer_url]) { @include $setup[footer_url]; }
			if($group[footer_url]) { @include $group[footer_url]; }
			if($group[header_url]) { $g_head = "layout/config/layout/".$group[header_url]."/setup.php"; }
			if($setup[header_url]) { $s_head = "layout/config/layout/".$setup[header_url]."/setup.php"; }
			if(is_file("$g_head")) { include $g_head; }elseif(is_file("$s_head")) { include $s_head; }
			if($miso_layout == "ok") include $_zb_path."layout/foot.php";
			?>
 
</body>
</html>
			<?
			
		} else {
 
			if($group[footer]) echo stripslashes($group[footer]);
			if($group[footer_url]) { @include $group[footer_url]; }
 
			?>
			</body>
			</html>
			<?
		}
 
		$_phpExcutedTime = (getmicrotime()-$_startTime)-($_sessionEnd-$_sessionStart)-($_nowConnectEnd-$_nowConnectStart)-$_dbTime-$_skinTime;
		// .[d N?
		echo "\n\n<!--"; 
		if($_sessionStart&&$_sessionEnd)  		echo"\n Session Excuted  : ".sprintf("%0.4f",$_sessionEnd-$_sessionStart);
		if($_nowConnectStart&&$_nowConnectEnd) 	echo"\n Connect Checked  : ".sprintf("%0.4f",$_nowConnectEnd-$_nowConnectStart);
		if($_dbTime)  							echo"\n Query Excuted  : ".sprintf("%0.3f",$_dbTime);
		if($_phpExcutedTime)  					echo"\n PHP Excuted  : ".sprintf("%0.3f",$_phpExcutedTime);
		if($_listCheckTime) 					echo"\n Check Lists : ".sprintf("%0.3f",$_listCheckTime);
		if($_skinTime) 							echo"\n Skins Excuted  : ".sprintf("%0.3f",$_skinTime);
   		if($_startTime) 						echo"\n Total Excuted Time : ".sprintf("%0.3f",getmicrotime()-$_startTime);
		echo "\n-->\n";
	}
 
 
	// zbLayer N?
	function check_zbLayer($data) {
		global $zbLayer, $setup, $member, $is_admin, $id, $_zbCheckNum;
		if($setup[use_formmail]) {
			if(!$_zbCheckNum) $_zbCheckNum=0;
			$data[name]=stripslashes($data[name]);
			$data[name]=urlencode($data[name]);
			//$data[name]=str_replace("\"","",$data[name]);
			//$data[name]=str_replace("'","\'",$data[name]);
			//$data[name]=str_replace(" ","",$data[name]);
 
			if($data[homepage]){
				$data[homepage]=str_replace("http://","",stripslashes($data[homepage]));
				//$data[homepage]=str_replace("\"","",$data[homepage]);
				//$data[homepage]=str_replace("'","",$data[homepage]);
				//$data[homepage]=str_replace(" ","",$data[homepage]);
				$data[homepage]=urlencode($data[homepage]);
				$data[homepage]="http://".$data[homepage];
			}
 
			$data[email]=base64_encode($data[email]);
 
			$_zbCheckNum++;
			$_zbCount=1;
 
			if(($member[is_admin]==1||$member[is_admin]==2)&&$data[ismember]) {
				$traceID = $data[ismember];
				$traceType="t";
				$isAdmin=1;
			} elseif(($member[is_admin]==1||$member[is_admin]==2)&&!$data[ismember]) {
				$traceID = $data[name];
				$traceType="tn";
				$isAdmin=1;
			}
 
			if($member[no]) $isMember = 1;
 
			if($data[ismember]<1) $data[ismember]="";
 
			$zbLayer = $zbLayer."\nprint_ZBlayer('zbLayer$_zbCheckNum', '$data[homepage]', '$data[email]', '$data[ismember]', '$id', '$data[name]', '$traceID', '$traceType', '$isAdmin', '$isMember');";
		}   
		return $_zbCount;
	}
	
 
	// .] m®Ö N?
	function error($message, $url="") {
		global $setup, $connect, $dir, $config_dir;
 
		$dir="skin/".$setup[skinname];
 
		if($url=="window.close") {
			$message=str_replace("<br>","\\n",$message);
			$message=str_replace("\"","\\\"",$message);
			?>
			<script>
				alert("<?=$message?>");
				window.close();
			</script>
			<?
		} else {
 
			head();
 
			if($setup[skinname]) {
				include "skin/$setup[skinname]/error.php";
			} else {
				include $config_dir."error.php";
			}
 
			foot();
 
		}
 
		if($connect) @mysql_close($connect);
 
		exit;
	}
 
 
	// j[× ²?Ê ?k%
	function get_table_attrib($id) {
 
		global $connect, $admin_table;
 
		$data=mysql_fetch_array(mysql_query("select * from $admin_table where name='$id'",$connect));
 
		if($data[table_width]<=100) $data[table_width]=$data[table_width]."%"; 
 
		// 3Z. IP? >y?. fߣI, DB ò3Ê t|f *?® ?.Ö "v .¨ ~2N ò3|y .¨
		if(!$data[use_showip]) $data[use_showip] = 1;
		$data[grant_imagebox] = $data[use_showip];
 
		return $data;
	}
 
 
	// j[×Ö .©¸  ..
	function istable($str, $dbname='') {
		global $config_dir;
		if(!$dbname) {
			$f=@file($config_dir."config.php") or Error("config.php
X(.<br>ËH-?Ç?«.","install.php");
			for($i=1;$i<=4;$i++) $f[$i]=str_replace("\n","",$f[$i]);
			$dbname=$f[4];
		}
 
		$result = mysql_list_tables($dbname) or error(mysql_error(),"");
 
		$i=0;
 
		while ($i < mysql_num_rows($result)) {
			if($str==mysql_tablename ($result, $i)) return 1;
			$i++;
		}
		return 0;
	}
 
 
	// £ß 4?tæ ?k. 4?t lv¾?  ?|y 4?t °c  ;à£Ö ..
	function check_blockip() {
		global $setup;
		$avoid_ip=explode(",",$setup[avoid_ip]);
		$count = count($avoid_ip);
		for($i=0;$i<$count;$i++) {
			if(!isblank($avoid_ip[$i])&&eregi($avoid_ip[$i],$REMOTE_ADDR)) Error("`?IP«b(,Ù.");
		}
	}
 
 
	// ~.à± ¹ü
	function getNowConnector($filename,$div) {
		global $_zbDefaultSetup;
		$_str = trim(zReadFile($filename));
		$num = 0;
		if($_str) {
			$_str = str_replace("<?/*","",$_str);
			$_str = str_replace("*/?>","",$_str);
			$_connector = explode(":",$_str);
			$_sizeConnector = count($_connector);
			$_nowtime = date("YmdHi");
			unset($_realNowConnector);
			if($_sizeConnector) {
				for($i=0;$i<$_sizeConnector;$i++) {
					$_time = substr($_connector[$i],0,12);
					$_div = substr($_connector[$i],12);
					if($_time+$_zbDefaultSetup[nowconnect_time]>=$_nowtime&&$_div!=$div) {
						$_realNowConnector.=$_time.$_div.":";
						$num++;
					}
				}
			}
		}
		$_realNowConnector.=$_nowtime.$div;
		//check_fileislocked($filename);
		zWriteFile($filename, "<?/*".$_realNowConnector."*/?>");
		return $num;
	}
 
	// ~.à± ?|f
	function getNowConnector_num($filename, $FLAG=FALSE) {
		global $_zbDefaultSetup;
		$_str = trim(zReadFile($filename));
		$num = 0;
		if($_str) {
			$_str = str_replace("<?/*","",$_str);
			$_str = str_replace("*/?>","",$_str);
			$_connector = explode(":",$_str);
			$_sizeConnector = count($_connector);
			$_nowtime = date("YmdHi");
			unset($_realNowConnector);
			if($_sizeConnector) {
				for($i=0;$i<$_sizeConnector;$i++) {
					$_time = substr($_connector[$i],0,12);
					$_div = substr($_connector[$i],12);
					if($_time+$_zbDefaultSetup[nowconnect_time]>=$_nowtime) {
						$_realNowConnector.=$_time.$_div.":";
						$num++;
					}
				}
			}
		}
		if($FLAG) {
			//check_fileislocked($filename);
			zWriteFile($filename, "<?/*".$_realNowConnector."*/?>");
		}
		return $num;
	}
 
 
	// ¯N>. àÕ N?£ ®®Ø? ..Ö ×=?® .2Ê ?! ØÊ l.
	function getZBSessionID() {
		global $HTTP_COOKIE_VARS, $_zb_path, $_zbDefaultSetup;
 
		$zbSessionID = $HTTP_COOKIE_VARS[ZBSESSIONID];
 
		if(!$zbSessionID) return "";
		$str = zReadFile($_zb_path.$_zbDefaultSetup[session_path]."/zbSessionID_".$zbSessionID.".php");
 
		if(!$str) {
			@setcookie("ZBSESSIONID", "", time()+60*60*24*365, "/");
			return "";
		}
 
		$str = explode("\n",$str);
 
		$data[no] = trim($str[1]);
		$data[time] = trim($str[2]);
 
		$newZBSessionID = md5($data[no]."-^A-".$data[time]);
 
		if($newZBSessionID != $zbSessionID) {
			@setcookie("ZBSESSIONID", "", time()+60*60*24*365, "/");
			return "";
		}
 
		if(!$_zb_path) {
			z_unlink($_zb_path.$_zbDefaultSetup[session_path]."/zbSessionID_".$zbSessionID.".php");
			makeZBSessionID($data[no]);
		}
 
		return $data;
	}
 
 
	// ¯N>. àÕ N?£ ®®ØÊ \.. ±
	function makeZBSessionID($no) {
		global $HTTP_COOKIE_VARS, $_zb_path, $_zbDefaultSetup;
 
		$zbSessionID = md5($no."-^A-".time());
 
		$newStr = "<?/*\n$no\n".time()."\n*/?>";
 
		zWriteFile($_zb_path.$_zbDefaultSetup[session_path]."/zbSessionID_".$zbSessionID.".php", $newStr);
 
		@setcookie("ZBSESSIONID", $zbSessionID, time()+60*60*24*365, "/");
	}
 
 
	// ¯N>. àÕ N?£ ®®Ø Ôf[H. ±
	function destroyZBSessionID($no) {
		global $HTTP_COOKIE_VARS, $_zb_path, $_zbDefaultSetup;
		$zbSessionID = $HTTP_COOKIE_VARS[ZBSESSIONID];
		z_unlink($_zb_path.$_zbDefaultSetup[session_path]."/zbSessionID_".$zbSessionID.".php");
		@setcookie("ZBSESSIONID", "", time()+60*60*24*365, "/");
	}
 
	// ¯N>.Ö fD ²? Ô~Ê ?k?. ±
	function getDefaultSetup() {
		global $_zb_path;
		$data = zReadFile($_zb_path."setup.php");
		$data = str_replace("<?/*","",$data);	
		$data = str_replace("*/?>","",$data);	
		$data = explode("\n",$data);
		$_c = count($data);
		unset($defaultSetup);
		for($i=0;$i<$_c;$i++) {
			if(!ereg(";",$data[$i])&&strlen(trim($data[$i]))) {
				$tmpStr = explode("=",$data[$i]);
				$name = trim($tmpStr[0]);
				$value = trim($tmpStr[1]);
				$defaultSetup[$name]=$value;
			}
		}
		if(!$defaultSetup[url]) $defaultSetup[url] = $HTTP_HOST;
		if(!$defaultSetup[sitename]) $defaultSetup[sitename] = $HTTP_HOST;
		if(!$defaultSetup[session_path]) $defaultSetup[session_path] = "data/__zbSessionTMP";
		if(!$defaultSetup[session_view_size]) $defaultSetup[session_view_size] = 512;
		if(!$defaultSetup[session_vote_size]) $defaultSetup[session_vote_size] = 256;
		if(!$defaultSetup[login_time]) $defaultSetup[login_time] = 60*30;
		if(!$defaultSetup[nowconnect_enable]) $defaultSetup[nowconnect_enable] = "true";
		if(!$defaultSetup[nowconnect_refresh_time]) $defaultSetup[nowconnect_refresh_time] = 60*3;
		if(!$defaultSetup[nowconnect_time]) $defaultSetup[nowconnect_tim] = 60*5;
		if(!$defaultSetup[enable_hangul_id]) $defaultSetup[enable_hangul_id] = "false";
		if(!$defaultSetup[check_email]) $defaultSetup[check_email] = "true";
		if(!$defaultSetup[memo_limit_time]) $defaultSetup[memo_limit_time] = 7;
		$defaultSetup[memo_limit_time] = 60 * 60 * 24 * $defaultSetup[memo_limit_time];
		 
		return $defaultSetup;
	}
 
 
	/******************************************************************************
 	 * ~i ±
 	 *****************************************************************************/
	// ´åàî 3¦ 1Ê l.
	function isblank($str) {
		$temp=str_replace("[","",$str);
		$temp=str_replace("\n","",$temp);
		$temp=strip_tags($temp);
		$temp=str_replace("&nbsp;","",$temp);
		$temp=str_replace(" ","",$temp);
		if(eregi("[^[:space:]]",$temp)) return 0;
		return 1;
	}
 
 
	// ?à~ 3¦ 1Ê l.
	function isnum($str) {
		if(eregi("[^0-9]",$str)) return 0;
		return 1;
	}
 
 
	// ?à, Yåà ~3¦ 1Ê l.
	function isalNum($str) {
		if(eregi("[^0-9a-zA-Z\_]",$str)) return 0;
		return 1;
	}
 
 
	// HTML Tag? ¯j|. ±
	function del_html( $str ) {
		$str = str_replace( ">", "&gt;",$str );
		$str = str_replace( "<", "&lt;",$str );
		return $str;
	}
 
 
	// ?.ÔYÓí ..
	function check_jumin($jumin) { 
		$weight = '234567892345'; // àl± weight Ö? 
		$len = strlen($jumin); 
		$sum = 0; 
 
		if ($len <> 13) return false;
 
		for ($i = 0; $i < 12; $i++) { 
			$sum = $sum + (substr($jumin,$i,1)*substr($weight,$i,1)); 
		} 
 
		$rst = $sum%11; 
		$result = 11 - $rst; 
 
		if ($result == 10) $result = 0;
		else if ($result == 11) $result = 1;
 
		$ju13 = substr($jumin,12,1); 
 
		if ($result <> $ju13) return false;
		return true; 
	} 
 
 
	// E-mail ?![ ¢%GÖ ..
	function ismail( $str ) {
		if( eregi("([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)", $str) ) return $str;
		else return ''; 
	}
 
	// E-mail Ö MX? .|y .¯ Dß|. m~£Ö ..
	function mail_mx_check($email) {
		if(!ismail($email)) return false;
		list($user, $host) = explode("@", $email);
		if (checkdnsrr($host, "MX") or checkdnsrr($host, "A")) return true;
		else return false;
	}
 
 
	// òô?Ö ?![ ¢%GÖ ..
	function isHomepage( $str ) {
		if(eregi("^http://([a-z0-9\_\-\./~@?=&amp;-\#{5,}]+)", $str)) return $str;
		else return '';
	}
 
 
	// URL, MailÊ àÕ2N ¹ü|y mü\ß
	function autolink($str) {
		// URL ?ù
		$homepage_pattern = "/([^\"\'\=\>])(mms|http|HTTP|ftp|FTP|telnet|TELNET)\:\/\/(.[^ \n\<\"\']+)/";
		$str = preg_replace($homepage_pattern,"\\1<a href=\\2://\\3 target=_blank>\\2://\\3</a>", " ".$str);
 
		// m~ ?ù
		$email_pattern = "/([ \n]+)([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)/";
		$str = preg_replace($email_pattern,"\\1<a onfocus=blur() href=javascript:void(window.open('sendmail.php?to=\\2@\\3','_blank','left=0,top=0,width=206,height=300'))>\\2@\\3</a>", " ".$str);
 
		return $str;
	}
 
 
	// Ô~ .?T? kb, mb. .zk® òù?® l.
	function getfilesize($size) {
		if(!$size) return "0 Byte";
		if($size<1024) { 
			return ($size." Byte");
		} elseif($size >1024 && $size< 1024 *1024)  {
			return sprintf("%0.1f KB",$size / 1024);
		}
		else return sprintf("%0.2f MB",$size / (1024*1024));
	}
 
 
	// åàî ?f (?;Ö .?~}. ... N R[)
	function cut_str($msg,$cut_size) {
		if($cut_size<=0) return $msg;
		if(ereg("\[re\]",$msg)) $cut_size=$cut_size+4;
		for($i=0;$i<$cut_size;$i++) if(ord($msg[$i])>127) $han++; else $eng++;
		$cut_size=$cut_size+(int)$han*0.6;
		$point=1;
		for ($i=0;$i<strlen($msg);$i++) {
			if ($point>$cut_size) return $pointtmp."...";
			if (ord($msg[$i])<=127) {
				$pointtmp.= $msg[$i];
				if ($point%$cut_size==0) return $pointtmp."..."; 
			} else {
				if ($point%$cut_size==0) return $pointtmp."...";
				$pointtmp.=$msg[$i].$msg[++$i];
				$point++;
			}
			$point++;
		}
		return $pointtmp;
	}
 
 
	// ô?Ö ?Õ vüc¾
	function movepage($url) {
		global $connect;
		echo"<meta http-equiv=\"refresh\" content=\"0; url=$url\">";
		if($connect) @mysql_close($connect);
		exit;
	}
 
	// input ³. textareaÖ .?T? ?Yæ Ûv~} ??|y l.
	function size($size) {
		global $browser;
		if(!$browser) return " size=".($size*0.6)." ";
		else return " size=$size ";
	}
 
	function size2($size) {
		global $browser;
		if(!$browser) return " cols=".($size*0.6)." ";
		else return " cols=$size ";
	}
 
 
	// m~ >.. ±
	function zb_sendmail($type, $to, $to_name, $from, $from_name, $subject, $comment, $cc="", $bcc="") {
		$recipient = "$to_name <$to>";
 
		if($type==1) $comment = nl2br($comment);
 
		$headers = "From: $from_name <$from>\n";
		$headers .= "X-Sender: <$from>\n";
		$headers .= "X-Mailer: PHP ".phpversion()."\n";
		$headers .= "X-Priority: 1\n";
		$headers .= "Return-Path: <$from>\n";
 
		if(!$type) $headers .= "Content-Type: text/plain; ";
		else $headers .= "Content-Type: text/html; ";
		$headers .= "charset=BIG5\n";
 
		if($cc)  $headers .= "cc: $cc\n";
		if($bcc)  $headers .= "bcc: $bcc";
 
		$comment = stripslashes($comment);
		$comment = str_replace("\n\r","\n", $comment);
 
		return mail($recipient , $subject , $comment , $headers);
 
	}
 
	// Ö?9 äÓ\lÖ Ô~ ?>? ?
	function get_dirinfo($path) {
 
		$handle=@opendir($path);
		while($info = readdir($handle)) {
			if($info != "." && $info != "..") {
				$dir[] = $info;
			}
		}
		closedir($handle);
		return $dir;
	}
 
	// Ô~Ê 	¯|. ±
	function z_unlink($filename) {
		@chmod($filename,0777);
		$handle = @unlink($filename);
		if(@file_exists($filename)) {
			@chmod($filename,0775);
			$handle=@unlink($filename);
		}
		return $handle;
	}
 
	// Ö?9 Ô~Ö .¨Ê ?k%
	function zReadFile($filename) {
		if(!file_exists($filename)) return '';
 
		$f = fopen($filename,"r");
		$str = fread($f, filesize($filename));
		fclose($f);
 
		return $str;
	}
 
	// Ö?9 Ô~. ?k. I?k? j
	function zWriteFile($filename, $str) {
		$f = fopen($filename,"w");
		$lock=flock($f,2);
		if($lock) {
			fwrite($f,$str);
		}
		flock($f,3);
		fclose($f);
	}
 
	// Ö?9 Ô~? Locking?£Ö ..
	function check_fileislocked($filename) {
		$f=@fopen($filename,w);
		$count = 0;
		$break = true;
		while(!@flock($f,2)) {
			$count++;
			if($count>10) {
				$break = false;
				break;
			}
		}
		if($break!=false) @flock($f,3);
		@fclose($f);
	}
 
	// Vù³2N äÓ\l? 	¯
	function zRmDir($path) { 
		$directory = dir($path); 
		while($entry = $directory->read()) { 
			if ($entry != "." && $entry != "..") { 
				if (Is_Dir($path."/".$entry)) { 
					zRmDir($path."/".$entry); 
				} else { 
					@UnLink ($path."/".$entry); 
				} 
			} 
		} 
		$directory->close(); 
		@RmDir($path); 
	}
?>

Open in new window

0
 
Ray PaseurCommented:
This error occurs because the foreach() control structure (iterator) expects its input to be an object or array.  If you search this page for http_get_vars...

http://us.php.net/manual/sl/reserved.variables.php

... you will see that while it is conceptually similar to $_GET, it is NOT automatically a "global" variable. $HTTP_GET_VARS and $_GET  are different variables and that PHP handles them as such.

Simply changing to use $_GET will not eliminate the condition that causes the error message; foreach does not support the ability to suppress error messages using '@'.

If the URL did not contain any GET arguments, $_GET will not be an array of key=>value pairs.  The other superglobal you address ($_POST, etc.) are handled using @extract, so this sort of error message will be suppressed if they are not present in the script's variable space.

A good test for this condition (empty url string) would be to add something like the code snippet.

And it's beside the point of the OP question, but using extract() on external input is a recipe for catastrophe.  If there are any unexpected elements in those arrays, maybe put in by a hacker, you will find unexpected variables injected into your namespace.

HTH, ~Ray
<?php
// ARE THERE ANY ARGS IN THE URL QUERY STRING?
if (empty($_GET))
{
   echo "NOTHING IN THE URL QUERY STRING";
}
if (!is_array($_GET))
{
   echo "HORRORS! THE QUERY STRING IS BOLLIXED";
}

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now