35 lines
1.3 KiB
PHP
35 lines
1.3 KiB
PHP
<?php
|
|
switch( @$_POST['act'] ) {
|
|
/* 03.05.2021 Обновление профиля */
|
|
case 'update':
|
|
if ($_POST['pole'])
|
|
$db -> free_sql2( 'ALTER TABLE `users` ADD `' . $_POST['t'] . '` ' . $_POST['pole'] . ' NULL' );
|
|
else
|
|
$db -> free_sql2( 'ALTER TABLE `users` ADD `' . $_POST['t'] . '` varchar(250) NULL' );
|
|
$db -> free_sql( "UPDATE `users` SET `" . $_POST['t'] . "` = '" . $_POST['txt'] . "' WHERE `id` = " . $_SESSION['user_id'] . ";" );
|
|
break;
|
|
case 'ava':
|
|
if ( $_FILES['file']['tmp_name'] ){
|
|
if ( preg_match( '/[.](jpg)|(jpeg)|(JPG)|(JPEG)$/', $_FILES['file']['name'] ) ){
|
|
require_once MYDIR . '/api/php/genpass.php';
|
|
$img_name = generate_password( 10 );
|
|
$source = $_FILES['file']['tmp_name'];
|
|
$target = MYDIR . '/img/avatars/' . $img_name . '.jpg';
|
|
copy( $source, $target );
|
|
}
|
|
require_once MYDIR . '/api/php/img2.php';
|
|
rimg ( $target, 740, 556, $target, $zip=80, $c=0 );
|
|
echo $img_name;
|
|
//узнаем старую аватарку и удаляем
|
|
unset( $a );
|
|
$a['id'] = $_SESSION['user_id'];
|
|
$ava = $db -> get_val( 'users', $a, 'ava' );
|
|
unlink( MYDIR . '/img/avatars/' . $ava . '.jpg' );
|
|
unset( $a );
|
|
$a['ava'] = $img_name;
|
|
$db -> update( 'users', $_SESSION['user_id'], $a );
|
|
}
|
|
break;
|
|
default:
|
|
}
|