Location: PHPKode > scripts > Linker IMG > linker-img/manage/wait.php
<?php

//=====================================
// LINKER Category Engine
//=====================================
// Filename : wait.php
// Path  : manage directory
// last update : 2002/07/13
// Desc : User submittd Link authenicate
//=====================================

//=====================================
// File include part
//=====================================
include ("./authen.php");
include ("../function/$Sdb_type.php"); 
include ("../function/main_func.php"); 
include ("../function/userfield_info.php");
include ("../$Slang/m_common.php"); 

//=====================================
// DB_LAYER
//=====================================

$db = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db); // for view category
$db1 = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);

//=====================================
// View Wait link
//=====================================

if (!$switch) {

$Spagecut =5;
$directbar_cut = 10;

$db1->query("select count(*) as total from LINKER_WAIT");
$allrow = $db1->nrecord();
$total = $allrow[total];
$page_num = ceil($total / $Spagecut); // total page num


$page = ($page) ? $page : 0;
$vstart = $Spagecut * $page;
$vend = $Spagecut;

$db1->query("select * from LINKER_WAIT order by sid desc  limit $vstart,$vend");
$link_total = $db1->numrow;

//=====================================
// Make Directbar button
//=====================================


$page_start = floor($page/$directbar_cut) * $directbar_cut ; 
$page_end=$page_start+$directbar_cut; 

for ($p=$page_start ; $p<$page_end  ; $p++ ) 
{	

	$view=$p+1;
	if ($p<$page_num) 
	{
		if ($page==$p) 	$direct_bar.="<b>$view</b>&nbsp;";
		else 	$direct_bar.="<a href='wait.php?page=$p'>$view</a>&nbsp;";

	}
}

if ($total>$vstart+$Spagecut) { 
$next_p=$page+1;
$next_list="<a href='wait.php?page=$next_p'>>></a>";
}


if ($page>0) {
$prev_p=$page-1;
$prev_list="<a href='wait.php?page=$prev_p'><<</a>&nbsp;";
}


if (!$total) { // No wait link
print <<<EOF
<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
</head>

<body bgcolor="#E9E9E9">

<table width="500" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$l_nowat_txt</font></b>
</td></tr></table>

</body></html>
EOF;
exit;
}


// Wait link head

print <<<EOF

<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
</head>

<body bgcolor="#E9E9E9">

<table border=0 cellpadding=0 cellspacing=1>
<tr>
<td colspan=2>

<table width="100%" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$total $l_wait_txt</font></b>
</td></tr></table>

</td>	</tr>

<tr><td colspan=2>&nbsp;</td>	</tr>

<tr>
<td  bgcolor='#E0E0E0' width='500' height='24' colspan=2>
&nbsp;<font size='2'>$prev_list  $direct_bar &nbsp;$next_list </font></td>
</tr>

<tr><td>

EOF;

//=====================================
// loop part
//=====================================


while ($row = $db1->nrecord()) {

$view_cat = view_category("sid","1",$row[parent]);
$row[title] = htmlspecialchars($row[title]);
$row[scont] = htmlspecialchars($row[scont]);
$row[lcont] = htmlspecialchars($row[lcont]);
$row[name] = htmlspecialchars($row[name]);
$upfile = unserialize(stripslashes($row[upfile]));
$upfile[2] = size_cut($upfile[2]);
$upfile[5] = strtoupper($upfile[5]);


// Pinrt output

print <<<EOF
	
<table border='0' cellpadding=0 cellspacing=1><form action='wait.php' method='post' ENCTYPE="multipart/form-data">
<input type='hidden' name='switch' value='add'>
<input type='hidden' name="sid" value='$row[sid]'>

<tr>
	<td width='100' bgcolor='#F6F6F6' height='24'><font size='2'>&nbsp;$l_title</font></td>
	<td bgcolor='#F6F6F6'><input type='text' name='title' size='20' maxlenght=40 style="width:290px" value="$row[title]"></td>
</tr>
<tr>
	<td width='100' bgcolor='#F6F6F6' height='24'><font size='2'>&nbsp;$l_source</font></td>
	<td  bgcolor='#F6F6F6'><input type='text' name='url' size='20' value="$row[url]" style="width:290px"></td>
</tr>
<tr>
	<td width='100' bgcolor='#F6F6F6' height='24'><font size='2'>&nbsp;$l_cat</font></td>
	<td bgcolor='#F6F6F6'><font size='2'><select name='parent'>$view_cat</select></font></td>
</tr>


<tr>
<td width='100' bgcolor='#F6F6F6' height='24'><font size='2'>&nbsp;$l_name</font></td>
<td  bgcolor='#F6F6F6'><input type='text' name='name' maxlength='40' size='20' value="$row[name]" style="width:290px">
</td>
</tr>

<tr>
<td width='100' bgcolor='#F6F6F6' height='24'><font size='2'>&nbsp;$l_email</font></td>
<td  bgcolor='#F6F6F6'><input type='text' name='email' maxlength='40' size='20' value="$row[email]" style="width:290px"></font></td>
</tr>


<tr>
<td width='100' bgcolor='#F6F6F6' height='27'><font size='2'>&nbsp;$l_edit_file</font></td>
<td bgcolor='#F6F6F6'>

	<table border=0 width=100%><tr>
	
	<td><ul>
	<li><font size='2'><a href="../download.php?sid=$row[sid]&type=wait">$upfile[0]</a></font></a></li>
	<li><font size='2'>($upfile[3] X $upfile[4], $upfile[2], $upfile[5])</font></li></ul>
	<input type='file' name="upfile" size='10'></td>

	<td align=right><a href='../imageview.php?uid=$upfile[1]&vtype=orgin' target='_blank'><img src='../imageview.php?uid=$upfile[1]' border=0></a></td>
	</tr></table>
	
</td>
</tr>


EOF;



//=====================================
//  User Filed
//=====================================

for ($k=1 ;$k<=5 ;$k++) {
$u_name = ${"u_user" . $k};
$u_fname = "user". $k;

if($u_name)
print <<<EOF

<tr>
<td width='100' bgcolor='#F6F6F6' height='24'><font size='2'>&nbsp;$u_name</font></td>
<td  bgcolor='#F6F6F6'><input type='text' name='$u_fname' maxlength='40' size='20' value="$row[$u_fname]" style="width:290px"></td>
</tr>

EOF;
}

//=====================================
//  Other output
//=====================================


print <<<EOF
<tr>
	<td width='100' height='24'  bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_pick</font></td>
	<td w height='24'  bgcolor='#F6F6F6'><font size='2'><select  name='c_pick'>
	<option selected value='0'>N</option>
	<option value='1'>Y</option></select></font></td>
</tr>

<tr>
<td width='100' bgcolor='#F6F6F6' height='24'><font size='2'>&nbsp;$l_pass</font></td>
<td  bgcolor='#F6F6F6'><input type='text' name="passwd" maxlength='10' size='10' value="$row[passwd]"></td>
</tr>

<tr>
<td width='100' bgcolor='#F6F6F6' height='24'><font size='2'>&nbsp;$l_scont</font></td>
<td bgcolor='#F6F6F6'><font size='2'><input type='text' name='scont' maxlength='150' size='25' value="$row[scont]" style="width:350px"></font></td>
</tr>

<tr>
<td width='100' bgcolor='#F6F6F6' height='24'><font size='2'>&nbsp;$l_lcont</font></td>
<td bgcolor='#F6F6F6'><textarea name='lcont' rows='5' cols='25' style="width:350px">$row[lcont]</textarea></td>
</tr>

<tr>
<td  colspan='2' bgcolor='#F6F6F6' height='24' align='center'>
<font size='2'><input type='submit' value='$l_addnmail' class=cinput></font></td>
</tr>

</form><form action='wait.php' method='post'>

<tr>
<td colspan='2' align=center bgcolor="#F6F6F6">
<textarea name='del_mail' rows='6' cols='40' style="width:450px">

$row[name] $l_addmail_txt
$Sadmin_mail

</textarea></td>
</tr>

<tr>
<td  colspan='2' bgcolor='#F6F6F6' height='24' align='center'>
<input type='hidden' name='switch' value='del'>
<input type='hidden' name='sid' value='$row[sid]'>
<input type='hidden' name='email' value='$row[email]'>
<font size='2'><input type='submit' value='$l_delnmail' class=cinput></font></td>
</tr>

<tr><td colspan=2 height=2 bgcolor="#999999" width=500></td></tr>

</form>
</table>

</td></tr></table><br><br>

EOF;


} // end while


} // end if

//===============================================================
//  Admin authenticate
//===============================================================


elseif ($switch=='add') {

while (list($key,$val) = each($HTTP_POST_VARS)) $$key = trim($val);

if (!$sid) errmsg($l_error_sidno);
if (!$title || !$parent)  errmsg($l_error_cattitle);


//---------------------------------
// file upload and user filed
//---------------------------------

$db->query("select upfile from LINKER_WAIT where sid='$sid'");
$frow = $db->nrecord();
$old_upfile = unserialize(stripslashes($frow[upfile]));


if ($upfile_name && $upfile_size >0)
{


	// delete old image file
	@unlink("../upfile/$old_upfile[1]");
	@unlink("../upfile/thumb_" . $old_upfile[1]);

	$file_ext = strtolower(substr($upfile_name,-strlen(strrchr($upfile_name,"."))+1));  // Get Image extension string
	$md5 = md5 (uniqid (rand()));


	
	if (ereg("jpg|png|gif", $file_ext)) 
	{

		$imginfo = @getimagesize ($upfile);

		switch ($imginfo[2]) 
		{
			case 1: $file_ext = "gif";		break;
			case 2: $file_ext = "jpg";	break;
			case 3: $file_ext = "png";	break;  
		}

		if ($imginfo[0] < $imginfo[1]) 
		{ 
				$file_width = intval($Snail_height * ($imginfo[0] / $imginfo[1])) ;
				$file_height = $Snail_height ;
		}
		
		else if ($imginfo[0] > $imginfo[1])
		{ 
				$file_height = intval($Snail_width * ($imginfo[1] / $imginfo[0]));
				$file_width = $Snail_width;
		}

		else 
		{
			if ($Snail_width < $Snail_height) 
			{
				$file_height = intval($Snail_width * ($imginfo[1] / $imginfo[0]));
				$file_width = $Snail_width;
			}
			else 
			{
				$file_width = intval($Snail_height * ($imginfo[0] / $imginfo[1])) ;
				$file_height = $Snail_height ;
			}
		}



		$dst_img = ImageCreate($file_width, $file_height);

		switch ($imginfo[2]) 
		{
			case 1: $src_img = ImageCreateFromgif($upfile);		break;
			case 2: $src_img = ImageCreateFromjpeg($upfile);	break;
			case 3: $src_img = ImageCreateFrompng($upfile);	break;
		}

		ImageCopyResized($dst_img, $src_img,0,0,0,0, $file_width, $file_height, ImageSX($src_img), ImageSY($src_img));

		switch ($imginfo[2]) 
		{
			case 1: Imagegif($dst_img, "../upfile/thumb_" . $md5 ,100);	break;
			case 2: Imagejpeg($dst_img, "../upfile/thumb_" . $md5 ,100);	break;
			case 3: Imagepng($dst_img, "../upfile/thumb_" . $md5 ,100);	break;
		}

		@ImageDestroy($dst_img);
		@ImageDestroy($src_img); 

	}

	$check_upload = move_uploaded_file($upfile, "../upfile/$md5");
	if ($check_upload) 
	{
		$add_filear[0]= $upfile_name;
		$add_filear[1]= $md5;
		$add_filear[2]= $upfile_size;
		$add_filear[3]= $imginfo[0];
		$add_filear[4]= $imginfo[1];
		$add_filear[5]= $file_ext;
		$add_filear[6]= 0;
		$add_file = serialize($add_filear);
		$img_uid = $md5;
	}
}	

else 
{
	$add_file = $frow[upfile];
	$img_uid = $old_upfile[1];
}

//----------------------------------------------

$maxnum = maxnum("LINKER_LINK","sid");
$time = time();



//---------------------------------
// parent last update time update
//---------------------------------

$db->query("select path,pathtxt,parent from LINKER_CAT where sid='$parent'");
$row = $db->nrecord();
$path = $row[path];
$pathtxt = $row[pathtxt];

$add_query = "insert into LINKER_LINK SET
sid = '$maxnum',
parent = '$parent',
title = '$title',
scont = '$scont',
lcont = '$lcont',
url = '$url',
uptime = '$time',
path = '$path',
pathtxt = '$pathtxt',
name = '$name',
email ='$email',
passwd = '$passwd',
upfile = '$add_file',
user1 = '$user1',
user2 = '$user2',
user3 = '$user3',
user4 = '$user4',
user5 = '$user5',
c_pick = '$c_pick',
c_new = '1'
";

$db->query($add_query);


//---------------------------------
// parent last update time update
//---------------------------------

$parent_array = @explode("/", $path);
for ($i=0; $i<count($parent_array) ;$i++) 
{
    $parent_last[] = "sid = $parent_array[$i]";
}
$parent_update = @implode(" or " , $parent_last);
$db->query("update LINKER_CAT set bingo1 = '$time' where $parent_update");


//---------------------------------
// plus sub_link num
//---------------------------------

$db->query("update LINKER_CAT set sub_link = sub_link+1 where sid='$parent'");
$db->query("delete from LINKER_WAIT where sid='$sid'");

//==================================
// send mail
//==================================

include ("../function/template.php");
$tpl = new Stemplate("../$Stemplate");

$tpl->define(	array( validate      => "validate_email.html" ));
$tpl->dyn_define ( "usercol", "validate" );


$pathtxt = str_replace($Ssepchar, $Sarrow,stripslashes($pathtxt));
$date = date("Y/m/d H:i:s",$time);


$tpl->assign(array( 
L_ADD_HERE	=> $l_here,
L_TITLE			=> $l_title,
L_SCONT		=> $l_scont,
L_LCONT		=> $l_lcont,
L_CON_SITE	=> $l_con_site,
L_NAME			=> $l_name,
L_EMAIL			=> $l_email,
L_UPTIME		=> $l_uptime,
L_PASS			=> $l_pass,

) );

$tpl->assign(array( 
DOMAIN			=> $Sdomain,
CHARSET		=> $Scharset,
SITE_NAME		=> $Ssite_name,
SITE_RESULT	=> $l_send_result,
PATHTXT		=> $pathtxt,
PARENT			=> $parent,
TITLE				=> $title,
SCONT			=> $scont,
NAME				=> $name,
EMAIL			=> $email,
URL				=> $url,
DATE				=> $date,
PASSWD		=> $passwd,
IMG_UID			=> $img_uid
) );


for ($k=1 ;$k<=5 ;$k++) 
{
$u_name = ${"u_user" . $k};
$u_value = ${"user". $k};


	if($u_name) 
	{
		$tpl->assign(array( 
		U_NAME		=> $u_name,
		U_VALUE		=> $u_value
		) );
		$tpl->parse("USERCOL",".usercol");
	}
}

$tpl->parse("PERMIT_MAIL","validate");
$permit_mail = $tpl->simfetch("PERMIT_MAIL");
send_mail($email,$l_mail_head,$permit_mail,"on");

//==================================
// Print output
//==================================

print <<<EOF
<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<meta http-equiv='refresh' content='2; url=wait.php'>
</head>

<body bgcolor="#E9E9E9">

<table width="500" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$url $l_mail_head</font></b>
</td></tr></table>
</body></html>

EOF;

} // end add


//============================
// Admin no permit
//============================


elseif ($switch=='del') {


if (!$sid) errmsg($l_error_sidno);


//---------------------------
// delete and del file
//---------------------------

$db->query("select upfile from LINKER_WAIT where sid='$sid'");
$row = $db->nrecord();
$upfile = @unserialize(stripslashes($row[upfile]));
@unlink("../upfile/$upfile[1]");
@unlink("../upfile/thumb_" . $upfile[1]);

$db->query("delete from LINKER_WAIT where sid='$sid'");

print <<<EOF

<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<meta http-equiv='refresh' content='2; url=wait.php'>
</head>

<body bgcolor="#E9E9E9">

<table width="500" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$l_noadd_txt</font></b>
</td></tr></table>

</body></html>

EOF;
send_mail($email,$l_noadd_txt,$del_mail);
}

?>
Return current item: Linker IMG