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

📄 profile.php

📁 flashget43的源代码 一个比较常用的下载程序
💻 PHP
📖 第 1 页 / 共 3 页
字号:
if(isset($req['load'])) {  		// user finished selection of file so try to upload the file now

	$_FILES['img1']['name'] = strtolower($_FILES['img1']['name']);            //make sure file name is lower case.
	$_FILES['img1']['name'] = str_replace(' ', '_', $_FILES['img1']['name']); //get rid of spaces
	$_FILES['img1']['name'] = str_replace('$', '_', $_FILES['img1']['name']); //get rid of '$'
	$file_name = $_FILES['img1']['name'];                                     //take the file name, and then get all the stuff after the last '.' (the file extension)
	$file_name = strrchr($file_name, '.');

	if(!in_array($file_name, $ext)){		//make sure file type is supported
		$error = $font . $msg['t23'];
		foreach( $ext as $exts ){$error .= $exts . " ";}
		$error .= '<br>&nbsp;<br>';
  	}

	if(!$error) {
		$file_size = $_FILES['img1']['size'];		//make sure file isn't too large
		if($file_size > $max_file_size) {
			$error = $font . $msg['t24'] . round(($file_size/1024), 0) . $msg['t25'] . round((( $max_file_size / 1024 ) ) , 2) . ' KB'. '<br>&nbsp;';
		}
	}

	if(!$error) {
		if ($_FILES['img1'] != ''){			//get the file type from mime types and upload file to directory
			$file_type  = '/error';
			if( $_FILES['img1']['type'] == "image/gif" )   {$file_type  = '.gif';}
			if( $_FILES['img1']['type'] == "image/pjpeg" ) {$file_type  = '.jpg';}
			if( $_FILES['img1']['type'] == "image/jpeg" )  {$file_type  = '.jpg';}
			if( $_FILES['img1']['type'] == "image/jpc" )   {$file_type  = '.jpg';}
			if( $_FILES['img1']['type'] == "image/bmp")    {$file_type  = '.bmp';}

			$fw = $ufolder . $req['change_id'];
			if(file_exists($fw . '.jpg')) { unlink($fw . '.jpg');}
			if(file_exists($fw . '.gif')) { unlink($fw . '.gif');}
			if(file_exists($fw . '.bmp')) { unlink($fw . '.bmp');}

			$newtofile  = $fw . $file_type; 	//name file with user id and save in profile image directory
			copy($_FILES['img1']['tmp_name'], $newtofile) or $error = $font . $msg['t26'] . '<br>&nbsp;';


   		} else { $error = $font . $msg['t27'] . '<br>&nbsp;';}
	}

	if(!$error) {	// Update user profile with new URL to picture

		$user = ChatServer::getUser($req['change_id']);

		$stmt = new Statement("SELECT profile FROM {$GLOBALS['fc_config']['db']['pref']}users WHERE id=?");
			$rs = $stmt->process($user['id']);

		if(($rec = $rs->next()) && $rec['profile']) {$profile = unserialize($rec['profile']);} else {$profile = array();}

		$profile['t12'] = $newtofile;
		$req = array_merge($fields, $profile, $req);

		$stmt = new Statement("UPDATE {$GLOBALS['fc_config']['db']['pref']}users SET profile=? WHERE id=?");
		$stmt->process(serialize($profile), $user['id']);

//		$req['userid'] = $user['id'];
	}
}

if(isset($req['TCpicture']) || $error) { 		// user clicked for upload of picture so show that page

	$user = ChatServer::getUser($req['change_id']);

	if(!$error) {
		foreach($fields as $k => $v) {$fields[$k] = $req[$k];} // update user profile fields first

		$stmt = new Statement("UPDATE {$GLOBALS['fc_config']['db']['pref']}users SET profile=? WHERE id=?");
		$stmt->process(serialize($fields), $user['id']);
	}

//	$req['userid'] = $user['id'];

	send_style_sheet($msg['t32']);
	print '<div align=center><b><h2>' . $msg['t32'] . '</h2></div>';
	if($error) print $error;
	print '<div align=center><table align=center border=0 cellpadding=2 cellspacing=0 width=60%>';
	print '<tr><td>&nbsp;</td></tr><tr><td><center>' . $msg['t28'] . '</td></tr>';
	print '<tr><td><center><form enctype="multipart/form-data" method="post" action="profile.php?userid=' . $user['id'] . '&lang=' . $req['lang'] . '"><input type="file" name="img1" size="60"></td></tr>';
	print '<input type="hidden" name="flashchatid" value="' . $req['flashchatid'] . '">';
	print '<input type="hidden" name="userid" value="' . $req['id'] . '">';
	print '<input type="hidden" name="lang" value="' . $req['lang'] . '">';
	if(isset($req['admin_user_edit'])) {
		print '<input type="hidden" name="admin_user_edit" value="true">';
		print '<input type="hidden" name="cid" value="' . $req['change_id'] . '">';
	}

	print '<tr><td>&nbsp;</td></tr><tr><td><center>' . $msg['t29'];

	foreach ( $ext as $exts ){print "$exts ";}

	print '</td></tr><tr><td><center>' . $msg['t30'] . round(( $max_file_size / 1024 ) , 2) . ' KB';
	print '</td></tr><tr><td>&nbsp;</td></tr><tr><td><center><input type="submit" name="load" value="' . $msg['t31'] . '"></td></tr><tr><td>&nbsp;</td></tr>';
	die ('</table></form></div></body></html>');
}


if(isset($req['TCsave'])) {	// user want to save the text in profile set and maybe also update password

	$user = ChatServer::getUser($req['change_id']);

	foreach($fields as $k => $v) {$fields[$k] = $req[$k];}
	$pwdmsg = ''; // fix
	$fields['t14'] = trim($fields['t14']);
	$fields['t15'] = trim($fields['t15']);

	if((strlen($fields['t14']) > 0) || (strlen($fields['t15']) > 0)){

		if((strlen($fields['t14']) < 1) || (strlen($fields['t15']) < 1)){$pwdmsg = $msg['t40'];}

		if((strlen($fields['t14']) > 0) && (strlen($fields['t15']) > 0)){	// password change
  			$stmt = new Statement("SELECT password FROM {$GLOBALS['fc_config']['db']['pref']}users WHERE id=?");
  			$rs = $stmt->process($user['id']);
			$pwdmsg = $msg['t39'];
			$rec = $rs->next();
 			if($fields['t14'] === $rec['password'] || md5($fields['t14']) === $rec['password']) {
				$stmt = new Statement("UPDATE {$GLOBALS['fc_config']['db']['pref']}users SET password=? WHERE id=?");
				if( $GLOBALS['fc_config']['encryptPass'] > 0 ) {$fields['t15'] = md5($fields['t15']);}
				$stmt->process($fields['t15'], $user['id']);
				$pwdmsg = $msg['t38'];
				}
			$fields['t14'] = '';
			$fields['t15'] = '';
			}
	}

	foreach($fields as $k => $v) { $fields[$k] = removeEvilTags($v);}

	if(trim(strlen($fields['t12'])) < 2) {
		$fw = $ufolder . $req['change_id'];
		if(file_exists($fw . '.jpg')) { unlink($fw . '.jpg');}
		if(file_exists($fw . '.gif')) { unlink($fw . '.gif');}
		if(file_exists($fw . '.bmp')) { unlink($fw . '.bmp');}
	}

	$stmt = new Statement("UPDATE {$GLOBALS['fc_config']['db']['pref']}users SET profile=? WHERE id=?");
	$stmt->process(serialize($fields), $user['id']);

	//update gender of user in chat
	$gender = strtoupper(substr($fields['t43'], 0, 1));
	$conn->process(array('c' => 'sgen', 'u' => $user['id'], 't' => ($gender != 'M' && $gender != 'F')? NULL : $gender));

//	$req['userid'] = $user['id'];
}

// display the user profile (default entry)


  	$edit = (isset($req['flashchatid']) && ($req['id'] != SPY_USERID) && $req['userid'] == $req['id']);
	if($req['admin_show_profile']) $edit = true;
  	if(!$edit_allowed){$edit = false;}

	$user = ChatServer::getUser($req['change_id']);
	if(!$edit) $user = ChatServer::getUser($req['userid']);

  	$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}users WHERE id=?");
  	$rs = $stmt->process($user['id']);

  	if(($rec = $rs->next()) && $rec['profile']) {

		$test_profile = unserialize($rec['profile']);

		if( is_array($test_profile) && array_key_exists('fullname', $test_profile)) {

			$profile['t01'] = $test_profile['fullname'];
			$profile['t04'] = $test_profile['age'];
			$profile['t05'] = $test_profile['email'];
			$profile['t06'] = $test_profile['msnm'];
			$profile['t07'] = $test_profile['site'];
			$profile['t10'] = $test_profile['icq'];
			$profile['t13'] = $test_profile['comments'];
			$profile['t41'] = $test_profile['aim'];
			$profile['t42'] = $test_profile['yim'];
			$profile['t43'] = $test_profile['gender'];
			$profile['t44'] = $test_profile['location'];

		} 
		else 
		{

			$profile = unserialize($rec['profile']);
			$profile['t13'] = str_replace('\\', '', $profile['t13']); // fix for those who enters multiple \

		}

  	} else {$profile = array();}


  	$req = array_merge($fields, $profile, $req);

	if($user) {
//	if(($req['userid'] > 0)) {

	send_style_sheet('"' . $user['login'] . '"');?>

<script language="Javascript">
<!--
function pwdIsValid() {
	if( document.fc_profile.t15 )
	if ( document.fc_profile.t15.value != document.fc_profile.t15b.value )
	{
		alert('<?php echo $msg['t67']?>');
		return false;
	}
	return true;
}
</SCRIPT>


<?php	if( $user['login'] != '' )print '<div align=center><h2>' . $msg['t18'] . '&quot;' . $user['login'] . '&quot;</h2></div>';

		print '<tbody><tr vAlign="top"><center><table align=center border=0 cellpadding=5 cellspacing=2 width="600">';

	 if($edit) {
		print '<form action="profile.php" method="post" name="fc_profile">';
		print '<input type="hidden" name="flashchatid" value="' . $req['flashchatid'] . '">';
		print '<input type="hidden" name="lang" value="' . $req['lang'] . '">';
		print '<input type="hidden" name="userid" value="' . $req['id'] . '">';
		if(isset($req['admin_user_edit'])) {
			print '<input type="hidden" name="admin_user_edit" value="hidden_edit">';
			print '<input type="hidden" name="cid1" value="' . $req['change_id'] . '">';
		}
	 }

		$width150 = '<tr><td  align="right" width="250">';
		$width450 = '</td><td width="450">';

		if(!$edit) { foreach($req as $k => $v) { if(!$v) {$msg[$k] = null;}}}
		if(!$edit) {
			//if( stripos(trim($req['t07']),'http://'))
				//{$req['t07'] = '<a href="' . $req['t07'] . '" target="_blank">' . Message::replaceBadWord($req['t07']) . '</a>';}
			//else { $t07 = Message::replaceBadWord($req['t07']);}
		}

		function showInfoLine($itm, $add='')
		{
			global $edit, $msg, $width150, $width450,$req;

			if( !$msg[$itm] && !$edit ) return;
			echo $width150;
			echo $msg[$itm];
			echo $width450;
			if( $edit )
			{
				echo '<input type="text" name="'.$itm.'" size="60" value="' . $req[$itm] . '">';
			}
			else
			{
				$s = Message::replaceBadWord($req[$itm]);
				if( $add == 'link') echo '<a href="' . $s . '" target="_blank">' . $s . '</a>';
				else
				if( $add == 'mail') echo '<a href="mailto:' . $s . '">' . $s . '</a>';
				else echo $s;
			}
			echo '</td></tr>';
		}

		showInfoLine('t01');
		showInfoLine('t02');
		showInfoLine('t44');
		showInfoLine('t03');
	?>

	<?php echo $width150?><?php echo $msg['t43']?><?php echo $width450?><?php if($edit) { echo htmlSelect('t43', $gender_arr, $req['t43']); } else { ?><?php echo Message::replaceBadWord($req['t43'])?><?php } ?></td></tr>

	<?php
		showInfoLine('t04');
		showInfoLine('t05', 'mail');
		showInfoLine('t07', 'link');
		showInfoLine('t08', 'link');
		showInfoLine('t41');
		showInfoLine('t42');
		showInfoLine('t10');
		showInfoLine('t06');
	?>



<?php	if($req['t12'] || $edit){
		echo $width150 . $msg['t12'] . $width450;
		if($edit) {
		if(is_writable($ufolder)) { ?>
			<input type="text" name="t12" size="60" value="<?php echo $req['t12']?>"><br><input type="submit" name="TCpicture" value="<?php echo $msg['t20']?>"><br><?php echo $msg['t21']?>
<?php 		} else { if($rec['roles'] == ROLE_ADMIN) { print 'Your folder ' . $ufolder . ' is not writable. Pictures are disabled.</td></tr>';  } }
	 	} else {
			if(substr($req['t12'], 0, 7) == 'http://' && $nick = strpos($req['t12'], 'nick_image')) {
				$req['t12'] = './' . substr($req['t12'], $nick);
				}
			if(substr($req['t12'], 0, 7) == 'http://') {?> <img src="<?php echo $req['t12']?>" border=0>
<?php 		} else {
				if($req['t12'] && file_exists($req['t12'])) {
					$size = getimagesize($req['t12']);
					if($size['0'] < $pictureWidth) { $pictureWidth = $size['0'];} ?>
					<a href="<?php echo $req['t12']?>" target="_blank"><img border=0 src="<?php echo $req['t12']?>" width=<?php echo $pictureWidth?> alt="<?php echo $msg['t34']?>"></a>
<?php 			}
			}
		}} ?>


<?php if($req['t13'] || $edit) echo $width150 . $msg['t13'] . $width450?>

<?php if($edit) { ?>
		<textarea name="t13" rows="6" cols="30"><?php echo $req['t13']?></textarea><?php } else { ?><?php if($req['t13'] || $edit) echo Message::replaceBadWord($req['t13'])?><?php } ?> <?if($req['t13'] || $edit) echo '</tr>'?>

<?php	if($edit) { ?>
		<?php echo $width150?><?php echo $width450?></tr>
		<?php echo $width150?><?php echo $width450?><?php echo $msg['t37']?></tr>
		<?php echo $width150?><?php echo $width450?><?php echo $pwdmsg?></tr>
		<?php echo $width150?><?php echo $msg['t35']?><?php echo $width450?><input type="password" name="t14" size="60" value=""></tr>
		<?php echo $width150?><?php echo $msg['t36']?><?php echo $width450?><input type="password" name="t15" size="60" value=""></tr>
		<?php echo $width150?><?php echo $msg['t66']?><?php echo $width450?><input type="password" name="t15b" size="60" value=""></tr>
<?php 	}

	if($edit) { ?>
		<?php echo $width150?><?php echo $width450?><input type="submit" name="TCsave" value="<?php echo $msg['t14']?>" onClick="javascript:return pwdIsValid();"></td></tr>
<?php 	}
	if($edit) { ?>
		<?php echo $width150?><?php echo $width450?><a href="profile.php?userid=<?php echo $user['id']?>&lang=<?php echo $req['lang']?>"><?php echo $msg['t15']?></a><br><?php echo $msg['t16']?> </td></tr>
<?php 	}

	if($edit && $req['roles'] == ROLE_USER) { die('</form></table></center></tr></tbody></div></div></body></html>');}

// show all available profiles

	if($showAllProfiles || $req['roles'] == ROLE_ADMIN )
	{// display a list of all profiles in users table
		
		//pages 
		$page_num = $_REQUEST['pg'];
		if( ($page_num == '') && !is_numeric($page_num) ) $page_num = 1;
		$page_num--;		
		$stmt = new Statement("SELECT count(*) users_amount FROM {$GLOBALS['fc_config']['db']['pref']}users WHERE profile <> ''");
		$rs = $stmt->process();

⌨️ 快捷键说明

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