www.gusucode.com > 图片存储_淘宝相册_免费网盘源代码 > functions.php

    <?php
class template
{
	function header($globalvars)
	{
		global $user_dat;
		define('usernav', '<a href="' . $_SERVER['PHP_SELF'] . '?action=upload">上传图片</a> | <a href="' . $_SERVER['PHP_SELF'] . '?action=imgdir">图片目录</a> | <a href="' . $_SERVER['PHP_SELF'] . '?user=profile">设置资料</a> | <a href="' . $_SERVER['PHP_SELF'] . '?user=logout">退出</a>');
		define('adminnav', '<a href="' . $_SERVER['PHP_SELF'] . '?admin=newuser">新用户</a> | <a href="' . $_SERVER['PHP_SELF'] . '?admin=displayusers">所有用户</a> | <a href="' . $_SERVER['PHP_SELF'] . '?admin=settings">修改设置</a>');
		
		if($globalvars->settings['anonymousup'] == "yes")
		{
			define('guestnav', '<a href="' . $_SERVER['PHP_SELF'] . '?user=upload">无需注册免费上传图片</a> <font color="CCCCCC">|</font> <a href="' . $_SERVER['PHP_SELF'] . '?user=register"><font color=red><b>注册就送20MB空间</b></font></a>  <font color="CCCCCC">|</font> <a href="' . $_SERVER['PHP_SELF'] . '?user=login">登陆</a>');
		} else {
			define('guestnav', '<a href="' . $_SERVER['PHP_SELF'] . '?user=register">注册</a> | <a href="' . $_SERVER['PHP_SELF'] . '?user=login">现在登陆</a>');
		}
		
		echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title> 零贴免费图片空间-免费淘宝相册-图片上传-图片存储空间-中国唯一的彻底免费图片上传网站 </title>
  <meta http-equiv="Content-Type"
 content="text/html; charset=gb2312">
 <meta name="keywords" content="免费图片空间,淘宝相册,图片上传,图片上传网站,图片存储空间" />
<meta name="description" content="专业淘宝相册,提供稳定的淘宝图片存储空间,支持相册批量上传、批量贴图。中国唯一的彻底免费的淘宝免费相册。">
<meta http-equiv=refresh content=30;url=http://www.0tie.com>
  <style type="text/css">
<!--
body,td,th {
	color: #333333;
	FONT-FAMILY:宋体;
	font-size: 13px;
}
a:link {
	color: #2757AF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #2757AF;
}
a:hover {
	text-decoration: underline;
	color: #7B9FE1;
}
a:active {
	text-decoration: none;
	color: #2757AF;
}
body {

	margin-left: 0px;
	margin-right: 0px;
	margin-top: 0px;
	margin-bottom: 0px;
}	
input {
    BORDER-RIGHT: #7c98c5 1px solid; 
	BORDER-TOP: #7c98c5 1px solid; 
	BACKGROUND: #fff; 
	BORDER-LEFT: #7c98c5 1px solid; 
	BORDER-BOTTOM: #7c98c5 1px solid; 
	HEIGHT: 20px
}
.del
{
    BORDER-RIGHT: #fff 1px solid; 
	BORDER-TOP: #fff 1px solid; 
	BACKGROUND: #fff; 
	BORDER-LEFT: #fff 1px solid; 
	BORDER-BOTTOM: #fff 1px solid; 
	HEIGHT: 20px
}
.copy{
	BORDER-RIGHT: #FFCCCC 1px dashed; 
	BORDER-TOP: #FFCCCC 1px dashed; 
	BACKGROUND: #CC0000; 
	BORDER-LEFT: #FFCCCC 1px dashed; 
	BORDER-BOTTOM: #FFCCCC 1px dashed; 
	HEIGHT: 20px
	width:110px;
	color:#fff;

	}
select {
    background-color: #F2F2F2; 
    color: #2554AA;
    font-family: Verdana;
    font-size: 11;
}
textarea{
    background-color: #F2F2F2; 
    color: #2554AA;
    font-family: Verdana;
    font-size: 11;
}
p{
MARGIN-TOP: 10px; 
COLOR: #999999; 
HEIGHT: 15px"
}
}
.style2 {font-size: 12px}
.style3 {font-size: 12px}
.style5 {color: #2757AF}
.sDiv1 {
	BORDER-RIGHT: #adadad 1px solid; PADDING-RIGHT: 5px; PADDING-LEFT: 10px; FLOAT: left; PADDING-TOP: 3px; HEIGHT: 12px
}
-->
 </style>
</head>
<body >
<center>
<DIV 
style="FLOAT: left;MARGIN-BOTTOM: 20px; WIDTH: 98%; BORDER-BOTTOM: #d9d9d9 1px solid; HEIGHT: 22px; BACKGROUND-COLOR: #f2f2f2">
<DIV class=blue 
style="PADDING-LEFT: 10px; FLOAT: left; WIDTH:60%; PADDING-TOP: 7px; HEIGHT: 22px" 
align=left>今天是'.date('Y年m月j日').'   欢迎来到<font color="red"><b>零贴[Http://www.0tie.com]</b></font><font color="#9900CC"><b>免费</b></font>图片空间网!
</DIV>


<style> 
#Marquee{FLOAT: left; height:22px; PADDING-TOP: 7px; overflow:hidden;width:20%;}
#Marquee li{color:red;height:16px; list-style:none} 
</style>  
<div id="Marquee">
<li>1.注册用户支持批量上传</li>
<li>2.注册就送20M免费空间</li>
<li>3.独到的积分系统随后就来</li>
</div>
<script>
var Mar = document.getElementById("Marquee");
var child_div=Mar.getElementsByTagName("li")
var picH = 16;//移动高度
var scrollstep=3;//移动步幅,越大越快
var scrolltime=30;//移动频度(毫秒)越大越慢
var stoptime=2000;//间断时间(毫秒)
var tmpH = 0;
Mar.innerHTML += Mar.innerHTML;
function start(){
if(tmpH < picH){
tmpH += scrollstep;
if(tmpH > picH )tmpH = picH ;
Mar.scrollTop = tmpH;
setTimeout(start,scrolltime);
}else{
tmpH = 0;
Mar.appendChild(child_div[0]);
Mar.scrollTop = 0;
setTimeout(start,stoptime);
}
}
onload=function(){setTimeout(start,stoptime)};
</script>


<DIV class=blue 
style="PADDING-RIGHT: 0px; FLOAT: right; WIDTH: 15%;PADDING-RIGHT: 7px; PADDING-TOP: 7px; HEIGHT: 28px" 
align=right><A 
onclick="JavaScript:window.external.addFavorite(\'http://www.freep.cn\',\'零贴-免费贴图-0tie.com\')" 
href="http://www.0tie.com#">收藏本站</A> <A 
onclick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://www.0tie.com\');" 
href="http://www.0tie.com#">设为首页</A> </DIV></DIV>
';

	

echo '<DIV style="WIDTH: 400px; HEIGHT: 70px" align=center><A 
href="http://www.0tie.com/"><IMG 
style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px"  src="images/logo.gif"></A></DIV><div style="PADDING-TOP:30px;WIDTH: 400px; HEIGHT: 50px" ><span style="color:#fff; font-size:8px;"><a href="http://www.0tie.com" id="bai"><b>淘宝搬家</b></a> <a href="http://www.0tie.com" id="bai"><b>淘宝图片搬家</b></a> <a href="http://www.0tie.com" id="bai"><b>51相册图片搬家</b></a> <a href="http://www.0tie.com" id="bai"><b>淘宝图片自动搬家</b></a> <a href="http://www.0tie.com" id="bai"><b>图片搬家</b></a></span></DIV>';

	switch($user_dat['rank'])
	{
		case admin:
			echo "<b>管理员控制台</b><br /><br />" . adminnav ." | ".  usernav;
		break;
		
		case normal:
			echo "<b>用户控制台</b><br /><br />" . usernav;
		break;
		
		case guest:
			echo guestnav;
		break;
		
		default:
			echo guestnav;
		break;
	}

	
	echo '
		
		 <div><img src="images/index_08.gif" alt="" height="2" width="535"></div><div align=center>
	
	    
		';
		if($globalvars->settings['header'] != null)
	{
		echo "<div>" . $globalvars->settings['header'] . "</div>";
	}
	}
	
	function footer($user_dat, $globalvars)
	{	

		if($globalvars->settings['footer'] != null)
	{
		echo "</div><div>" . $globalvars->settings['footer'] ."</div>";
	}
		echo '<DIV style="BORDER-RIGHT: #ffcc99 1px solid; PADDING-RIGHT: 7px; BORDER-TOP: #ffcc99 1px solid; MARGIN-TOP: 40px; PADDING-LEFT: 7px; FONT-SIZE: 14px; BACKGROUND: #ffffe6; PADDING-BOTTOM: 7px; BORDER-LEFT: #ffcc99 1px solid; WIDTH: 585px; COLOR: #ff0099; PADDING-TOP: 7px; BORDER-BOTTOM: #ffcc99 1px solid; FONT-FAMILY: Arial; HEIGHT: 25px" 
align=center><A 
href="http://www.0tie.com/">免费相册</A>:上传图片可以外链到淘宝、易趣、拍拍、有啊;支持批量上传</DIV><!-- 广告区域结束 --><!-- 公告区域开始 -->
<DIV style="MARGIN-TOP: 10px; WIDTH: 600px; COLOR: #999999; HEIGHT: 20px" 
align=center><IMG src="images/lamp.gif" 
align=absMiddle>&nbsp;禁止上传涉及色情、暴力、恐怖等非法内容的图片! <!-- 公告区域结束 -->
<DIV style="MARGIN-TOP: 7px; DISPLAY: none" align=center> </DIV><!-- 友情链接开始<a href="http://www.zhuaban.com" target="_blank">抓伴中国</a> -->
<DIV style="CLEAR: both"></DIV><!-- 版权与备案开始 -->
<DIV class=gray 
style="MARGIN-TOP: 15px; WIDTH: 600px; COLOR: #999999; LINE-HEIGHT: 160%; HEIGHT: 30px" 
align=center>&copy;版权所有<a href="http://www.0tie.com">零贴网 2009-2010 中国最大的免费图片存储空间</a> <BR>
<script src="http://s175.cnzz.com/stat.php?id=1761451&web_id=1761451&show=pic" language="JavaScript" charset="gb2312"></script>
</DIV><!-- 版权与备案结束 --></DIV>
	</body>
	</html>';
	
	
	
	echo'</body>
	</html>';
	}
	
	function install_footer()
	{
				echo '<p><br>
			</p>
		</center>
		<p> </p>
		</td>
		</tr>
		<tr>
		<td> <img src="images/index_08.gif" alt="" height="4" width="535"></td>
		</tr>
		<tr>
      <td align="left" background="images/index_09.gif" nowrap="nowrap"
	valign="top"> <span class="style2"><center>安装未完成</center><font face="Arial"></font></span></td>
		</tr>
		<tr>
      <td colspan="3" align="center" background="images/index_10.gif"
	height="54" valign="middle"><span class="style2"> Copyright IMG
	Upload, by <a href="http://hellscythe.net">Hellscythe</a></span></td>
	</tr>
	</tbody>
	</table>
	</body>
	</html>';
	}
	
	function exitp($user_dat, $globalvars)
	{
		$footer = new template();
		$footer->footer($user_dat, $globalvars);
		exit();
	}
	
	function exitp_i()
	{
		$footer = new template();
		$footer->install_footer();
		exit();
	}
}

class global_vars
{
	var $maindir;
	var $settings;
	var $serverurl;
	
	function set_vars()
	{
		$split_path = explode('index.php', $_SERVER['PHP_SELF']);
		$this->serverurl = "http://" . $_SERVER['SERVER_NAME'] . $split_path[0];
		
		$this->maindir = "users/";
		
		$settings_query = mysql_query("select * from imgup_config ");
		$this->settings = mysql_fetch_array($settings_query);
	}
}

//公用函数
class functions
{
	//换算大小 由 Bytes → KB , MB
	function size_check($filesize)
	{
		if($filesize >= 1024)
		{
			$filesize = $filesize/1024;
			if($filesize>1024){
				$filesize = $filesize/1024; 
				$filesize = round($filesize, 1) ." MB.";
			}else{
				$filesize = round($filesize, 1)." KB.";
			}
		}else{
			$filesize = $filesize." bytes.";
		}
		return $filesize;
	}
	
	function mb_bytes($in_mb)
	{	
		return $in_mb * 1048576;
	}
	
	function kb_bytes($in_kb)
	{		
		return $in_mb * 1024;
	}
	
	function saveThumbnail($saveToDir, $imagePath, $imageName, $max_x, $max_y) 
	{
	// Function coded by: FearINC at gmail dot com
	// I do not take any credit for this function. I just found this function very useful, and decided to use it for my script.
	if(function_exists("imagejpeg"))
	{
	preg_match("'^(.*)\.(gif|jpe?g|png)$'i", $imageName, $ext);
	
	switch (strtolower($ext[2])) 
	{
		case 'jpg' :
		case 'jpeg': 
			$im  = imagecreatefromjpeg($imagePath);
        break;
		
		case 'gif':
			$im  = imagecreatefromgif($imagePath);
        break;
		
		case 'png': 
			$im  = imagecreatefrompng($imagePath);
        break;
		
		case 'bmp':
			$im = imagecreatefromwbmp($imagePath);
		break;
		
		default: 
			$stop = true;
        break;
   }
  
   if (!isset($stop)) 
   {
		$x = imagesx($im);
		$y = imagesy($im);
  
		if (($max_x/$max_y) < ($x/$y)) 
		{
			$save = imagecreatetruecolor($x/($x/$max_x), $y/($x/$max_x));
		} else {
			$save = imagecreatetruecolor($x/($y/$max_y), $y/($y/$max_y));
		}
		
		imagecopyresized($save, $im, 0, 0, 0, 0, imagesx($save), imagesy($save), $x, $y);
		imagegif($save, "{$saveToDir}{$ext[1]}.gif");
		imagedestroy($im);
		imagedestroy($save);
   }
	}
	}
}

$exitp = new template();
$template = new template();
$globalvars = new global_vars();
?>