32 lines
926 B
PHP
Executable File
32 lines
926 B
PHP
Executable File
<?php
|
|
switch( @$_POST['act'] ) {
|
|
case 'new_category':
|
|
|
|
|
|
|
|
serialize ( $_SESSION )
|
|
|
|
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:
|
|
}
|