View file bclubs/admin/adds.php

File size: 3.35Kb
<?php

/* Автор localhost
/* Онлайн игра Бойцовский клуб
/* Добавление соперника
*/

	if (isset($_POST['sop']))
	{

				require ('../inc/class_upload.php');

				$handle = new upload($_FILES['imagefile']);

				$fname = strtolower($_FILES['imagefile']['name']);
				$name = isset($_POST['name']) ? trim($_POST['name']) : '';
				$opis = isset($_POST['opis']) ? trim($_POST['opis']) : '';
				$level = isset($_POST['level']) ? abs(intval(trim($_POST['level']))) : '';
				$balls = isset($_POST['balls']) ? abs(intval(trim($_POST['balls']))) : '';

				if ($handle->uploaded)
				{
							$nams = time();
							$handle->file_new_name_body = $nams;

							$handle->allowed = array('image/jpeg', 'image/gif', 'image/png');
							$handle->file_max_size = 1024 * 100009090;
							$handle->file_overwrite = true;
							$handle->image_resize = true;
							$handle->image_x = 50;
							$handle->image_y = 50;
							$handle->image_convert = 'png';
							$handle->process('../img_sop/');
							if ($handle->processed)
							{

										mysql_query("INSERT INTO `game_soper` SET
                                    `name` = '" . mysql_real_escape_string($name) . "',             
                                    `level` = '" . intval($level) . "',                     
                                    `opyt` = '" . intval($balls) . "',
                                    `opis` = '" . $opis . "',
                                    `img` = '" . $nams . "'");

							}
							else
							{

										$err[] = $handle->error;

							}

							$handle->clean();

				}
				echo 'Боец успешно добавлен<br />';
	}
	err();
	$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `game_soper`"), 0);
	$req = mysql_query("SELECT * FROM `game_soper` ORDER BY `id`");
	while ($res = mysql_fetch_assoc($req))
	{
				echo $i % 2 ? '<div class="rek">' : '<div class="rek2">';

				echo '<table style="padding-left:0.1em;">';
				echo '<tr>';
				echo '<td >';
				echo '<img src="../img_sop/' . $res['img'] . '.png" />';
				echo '</td>';
				echo '<td>';
				echo '<div>';
				echo '' . $res['name'] . '&nbsp;<a href="?act=delete&amp;id=' . $res['id'] . '">del</a>';
				echo '</div>';
				if ($res['opis'])
				{

							echo '' . $res['opis'] . '';
							echo '<br/>';
				}
				echo '<div class="sub">';
				echo 'Опыт:&nbsp;' . $res['opyt'] . '&nbsp;|&nbsp;';
				echo 'Уровень:&nbsp;' . $res['level'] . '';
				echo '<br/>';
				echo '</div>';
				echo '</td>';
				echo '</tr>';
				echo '</table>';
				echo '</div>';
				++$i;
	}
	echo '<div class="line"></div>';
	echo '<form enctype="multipart/form-data" method="post" action="?act=adds">';
	echo 'Имя бойца<br /><input type="text" name="name" value="" maxlength="64" />';
	echo '<br />Изображение<br /><input type="file" name="imagefile" value="" />';
	echo '<br />Уровень доступа<br /><input type="text" name="level" size="3" value="" maxlength="3" />';
	echo '<br />Опыт за победу над ним<br /><input type="text" size="3" name="balls" value="" maxlength="32" />';

	echo '<br /><input type="submit" name="sop" value="Добавить" />';
	echo '</form>';
	echo '<div class="blc"><a href="index.php">Админка</a></div>';

?>